Message400403
Below is the example as it is. Currently self.quit clobbers a built-in method of the same name. I would suggest renaming self.quit to self.quit_button or similar.
-------------------------------------------------------
import tkinter as tk
class Application(tk.Frame):
def __init__(self, master=None):
super().__init__(master)
self.master = master
self.pack()
self.create_widgets()
def create_widgets(self):
self.hi_there = tk.Button(self)
self.hi_there["text"] = "Hello World\n(click me)"
self.hi_there["command"] = self.say_hi
self.hi_there.pack(side="top")
self.quit = tk.Button(self, text="QUIT", fg="red",
command=self.master.destroy)
self.quit.pack(side="bottom")
def say_hi(self):
print("hi there, everyone!")
root = tk.Tk()
app = Application(master=root)
app.mainloop()
-----------------------------------------------------------
>>> help(app.quit)
Help on method quit in module tkinter:
quit() method of __main__.Application instance
Quit the Tcl interpreter. All widgets will be destroyed. |
|
Date |
User |
Action |
Args |
2021-08-27 09:03:24 | lyndon.darcy | set | recipients:
+ lyndon.darcy, docs@python |
2021-08-27 09:03:24 | lyndon.darcy | set | messageid: <1630055004.62.0.378999176997.issue45029@roundup.psfhosted.org> |
2021-08-27 09:03:24 | lyndon.darcy | link | issue45029 messages |
2021-08-27 09:03:24 | lyndon.darcy | create | |
|