I want to select a file from a dialog box. Here is code that does all I need, but when I run it:
ImportError: No module named 'tkMessageBox'
How can I make this example work with Python 3?
解决方案
The package Tkinter has been renamed to tkinter in Python 3, as well as other modules related to it. Here are the name changes:
Tkinter → tkinter
tkMessageBox → tkinter.messagebox
tkColorChooser → tkinter.colorchooser
tkFileDialog → tkinter.filedialog
tkCommonDialog → tkinter.commondialog
tkSimpleDialog → tkinter.simpledialog
tkFont → tkinter.font
Tkdnd → tkinter.dnd
ScrolledText → tkinter.scrolledtext
Tix → tkinter.tix
ttk → tkinter.ttk
I advise you to learn how to dynamically browse the modules with the dir command. If you are under windows, configure Python to use readline module to get auto-completion and make it much easier to list available classes in a module.