import Tkinter - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: import Tkinter (/thread-25334.html) |
import Tkinter - orestgogosha - Mar-27-2020 my code: #!/usr/bin/env python import Tkinter as tk class Application(tk.Frame): def __init__(self, master=None): tk.Frame.__init__(self, master) self.grid() self.createWidgets() def createWidgets(self): self.quitButton = tk.Button(self, text='Quit', command=self.quit) self.quitButton.grid() app = Application() app.master.title('Sample application') app.mainloop()error messages Don't understandRE: import Tkinter - DT2000 - Mar-27-2020 orestgogosha, what version of python are you using? "Tkinter" is from post python 3x To have the code work simply change the "Tkinter" in your import line to "tkinter" (proper for python versions 3x). Keep in mind that when you run this code it will not close correctly when you click the Exit button because there is no definition statement in the code. I'll let you code that in for learning purposes. #!/usr/bin/env python #Changed Tkinter to tkinter for python versions 3x. import tkinter as tk class Application(tk.Frame): def __init__(self, master=None): tk.Frame.__init__(self, master) self.grid() self.createWidgets() def createWidgets(self): self.quitButton = tk.Button(self, text='Quit', command=self.quit) self.quitButton.grid() app = Application() app.master.title('Sample application') app.mainloop() |