[New-bugs-announce] [issue45029] tkinter doc, hello world example - quit button clobbers method

Lyndon D'Arcy report at bugs.python.org
Fri Aug 27 05:03:24 EDT 2021


New submission from Lyndon D'Arcy <lyndon.darcy at gmail.com>:

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.

----------
assignee: docs at python
components: Documentation, Tkinter
messages: 400403
nosy: docs at python, lyndon.darcy
priority: normal
severity: normal
status: open
title: tkinter doc, hello world example - quit button clobbers method
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45029>
_______________________________________


More information about the New-bugs-announce mailing list