Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
OOP Label In Tkinter
#3
You want to pack the widget you created, not the parent. And generally you don't modify the parent object, you keep track of the widgets yourself (put them in a list or a dict or something). Also, using a variable called "self" when it's not referring to an object reference is non-standard. I'd rename that variable in your function.

I would try:

def labels(master,text):
    var = StringVar()
    var.set(text)
    mylabel = Label(master,text=var)
    mylabel.pack()
Reply


Messages In This Thread
OOP Label In Tkinter - by Harshil - Aug-21-2020, 06:07 PM
RE: OOP Label In Tkinter - by Axel_Erfurt - Aug-21-2020, 07:12 PM
RE: OOP Label In Tkinter - by bowlofred - Aug-21-2020, 07:14 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  how to open a popup window in tkinter with entry,label and button lunacy90 1 945 Sep-01-2023, 12:07 AM
Last Post: lunacy90
  Use Function in Tkinter Label bigfatgreedykat 0 2,690 Jan-10-2018, 10:03 AM
Last Post: bigfatgreedykat

Forum Jump:

User Panel Messages

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