[issue35086] tkinter docs: errors in A Simple Hello World Program
New submission from Daniel Lovell : In the documentation for tkinter, "A Simple Hello World Program" Application class does not hold onto the master Tk() instance as a class attribute. This is a good practice, and newcomers to tkinter would likely have trouble closing the window without this since root will almost never be in the global namespace. The original example: """"" import tkinter as tk class Application(tk.Frame): def __init__(self, master=None): super().__init__(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=root.destroy) self.quit.pack(side="bottom") def say_hi(self): print("hi there, everyone!") root = tk.Tk() app = Application(master=root) app.mainloop() """" The proposed fix: """" 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!") def main(): root = tk.Tk() app = Application(master=root) app.mainloop() if __name__ == "__main__": main() """" -- components: Tkinter files: tkinter_hello_world_issue.png messages: 328669 nosy: NuclearLemon priority: normal severity: normal status: open title: tkinter docs: errors in A Simple Hello World Program type: enhancement versions: Python 3.7, Python 3.8 Added file: https://bugs.python.org/file47894/tkinter_hello_world_issue.png ___ Python tracker <https://bugs.python.org/issue35086> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35086] tkinter docs: errors in A Simple Hello World Program
Change by Daniel Lovell : -- keywords: +patch pull_requests: +9484 stage: -> patch review ___ Python tracker <https://bugs.python.org/issue35086> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35086] tkinter docs: errors in A Simple Hello World Program
Daniel Lovell added the comment: Thanks for the reply xtreak. I agree that changing the example to include main() isn't necessary - I unintentionally included that from my example of the case where the current version isn't functional. In the PR I submitted on Github (https://github.com/python/cpython/pull/10160), the proposed change is simply adding the master Tk instance to self.master then using that to close the window in the Quit button callback. Sorry for the confusion. -- ___ Python tracker <https://bugs.python.org/issue35086> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35142] html.entities.html5 should require a trailing semicolon
New submission from Daniel Lovell : html.entities.html5 keys should either require a trailing semicolon. The Python docs say: html.entities.html5 "A dictionary that maps HTML5 named character references [1] to the equivalent Unicode character(s), e.g. html5['gt;'] == '>'. Note that the trailing semicolon is included in the name (e.g. 'gt;'), however some of the names are accepted by the standard even without the semicolon: in this case the name is present with and without the ';'. See also html.unescape()." https://docs.python.org/3/library/html.entities.html?highlight=html However, it is not clear without looking at the source which keys require the semicolon and which do not. Taking a look at the source, the number which require a trailing semicolon vastly outnumber the others. For simplicity and continuity with the w3.org standard HTML5 Character Entity Reference Chart - I recommend that the trailing semicolon be required. As they are in HTML5: https://dev.w3.org/html5/html-author/charref My recommendation could then be extrapolated to say we should require the ampersand as HTML5 does, but I don't think this revision should be taken this far unless others agree. -- components: Library (Lib) messages: 329105 nosy: daniellovell priority: normal severity: normal status: open title: html.entities.html5 should require a trailing semicolon type: behavior versions: Python 3.7 ___ Python tracker <https://bugs.python.org/issue35142> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35142] html.entities.html5 should require a trailing semicolon
Daniel Lovell added the comment: Ah, I stupidly overlooked that as I'm only familiar with this HTML5 specification: https://html.spec.whatwg.org/multipage/syntax.html#character-references Where it states that characters MUST be terminated with a semicolon. Honestly never seen it done otherwise. -- resolution: not a bug -> status: closed -> open ___ Python tracker <https://bugs.python.org/issue35142> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35142] html.entities.html5 should require a trailing semicolon
Daniel Lovell added the comment: I'm setting this back to closed as I unintentionally reopened. Please forgive me as I'm new to the Python BPO. However, I did mean to continue the conversation if not reopen the issue. -- resolution: -> not a bug status: open -> closed ___ Python tracker <https://bugs.python.org/issue35142> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com