J
J
JustHacker2017-04-21 21:45:24
Python
JustHacker, 2017-04-21 21:45:24

Why doesn't the tkFileDialog module work?

So I decided to write a desktop program in Python 3.2 (do not ask what this module is for) and wrote the following code in the import:

from tkinter import *
import tkFileDialog

And then I write:
def LoadFile(ev):
    fn = tkFileDialog.Open(root, filetypes=[('*.txt files', '.txt')]).show()
    if fn == '':
        return
    textbox.delete('1.0', 'end')
    textbox.insert('1.0', open(fn, 'rt').read())

It throws: NameError: global name 'tkFileDialog' is not defined.
Maybe you need to download tkFileDialog? If so, where?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
stalker320, 2017-11-29
@stalker320

correction of the first part:
from tkinter import *
from tkinter.filedialog import and what you need in this library separated by commas (or *)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question