Oct-04-2020, 09:11 PM
(This post was last modified: Oct-04-2020, 09:11 PM by ReDefendeur.)
Hello,
I'm ReDefendeur and I would like to tell you about a potential bug that I found in Tkinter.
When we do widget.winfo_class()
this returns the class of the widget so I use it with a getattr(object, name[, default]) however for the class
LabelFrame, it returns Labelframe (no Shift to "F") which creates an error
I'm ReDefendeur and I would like to tell you about a potential bug that I found in Tkinter.
When we do widget.winfo_class()
this returns the class of the widget so I use it with a getattr(object, name[, default]) however for the class
LabelFrame, it returns Labelframe (no Shift to "F") which creates an error
import tkinter as tk root = tk.Tk() widget = tk.LabelFrame(root) widget_class = widget.winfo_class() # with bad class print(widget_class) try: getattr(tk, widget_class)(root) print("OK") except AttributeError: print("ERROR") # corrected if widget_class == "Labelframe": widget_class = "LabelFrame" try: getattr(tk, widget_class)(root) print("OK") except AttributeError: print("ERROR")
Output:Labelframe
ERROR
OK
Thank you for your answers