Tkinter in python 2.7 to 3.6 -
this code snippets trying out.
in python-2.7 changed 1 line found needed changed:
from tkinter import *
to
from tkinter import *
well... very wrong on that.
guess moduals got removed between python-2.7 , python-3???
causes modualnotfounderror
whenever try run it.
these moduals:
tkfiledialog tkmessagebox
those modules named filedialog
, messagebox
.
you can check tkinter documentation on modules more information
update:
see example tkinter on python 3.
from tkinter import * tkinter import messagebox, filedialog window_size = '200x100' top = tk() top.geometry(window_size) def msgbox_hello(): messagebox.showinfo('messagebox title', 'messagebox content') def filedialog_world(): file_name = filedialog.askopenfilename() # display file name if file_name: messagebox.showinfo( 'selected file name', 'you selected "{}"'.format(file_name)) b1 = button(top, text="msgbox", command=msgbox_hello) b1.pack(side=top, fill='x') b2 = button(top, text="filedialog", command=filedialog_world) b2.pack(side=top, fill='x') b3 = button(top, text="exit", command=exit) b3.pack(side=bottom, fill='x') top.mainloop()
Comments
Post a Comment