Python Forum
Issue in Tkinter with winfo_class() and LabelFrame
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Issue in Tkinter with winfo_class() and LabelFrame
#1
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

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
Reply
#2
Hi ReDefendeur, I'm not really familiar with tkinter. So I can't tell if this is really a bug. Anyway, this forum is not really the place for reporting potential bugs. Probably this is the right place for you to look: https://docs.python.org/3/bugs.html
- Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid. Albert Einstein
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  tkinter destroy label inside labelFrame Nick_tkinter 3 4,479 Sep-17-2023, 03:38 PM
Last Post: munirashraf9821
  [Tkinter] can i had a cefpython3 to a labelframe razs 25 10,905 Sep-15-2023, 01:38 PM
Last Post: munirashraf9821
Lightbulb [Tkinter] Tkinter Class Import Module Issue AaronCatolico1 6 2,967 Sep-06-2022, 03:37 PM
Last Post: AaronCatolico1
  Super basic tkinter arduino issue Kurta 3 2,376 Jan-07-2021, 05:22 PM
Last Post: deanhystad
Photo tkinter issue mate 4 2,501 Dec-06-2020, 09:03 PM
Last Post: mate
  [Tkinter] tkinter: after issue edwin6938 1 3,348 Aug-25-2020, 04:37 PM
Last Post: Larz60+
  Tkinter: increasing numbers and Radiobutton issue PeroPuri 1 2,118 Apr-13-2020, 05:48 PM
Last Post: deanhystad
  [Tkinter] tkinter issue with variables carrying over between functions PengEng 1 1,700 Apr-06-2020, 06:13 PM
Last Post: deanhystad
  Issue on tkinter with buttons Reldaing 1 2,414 Jan-07-2020, 08:21 AM
Last Post: berckut72
  [Tkinter] Tkinter window issue frequency 4 3,297 Dec-24-2018, 10:49 AM
Last Post: frequency

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020