I am extending the tk widgets to make a gui app. The problem is that I can put them on the main window without an error, but they are not visible. I have called the super constructor, but it still not showing up. i even tried to use ai to debug it, but that din't work to, so I am asking for help
from tkinter import *
from functions import *
class InventoryLabel (Label):
def __init__(self, master=None, **kwargs):
super().__init__(master, **kwargs)
self.config(text=transform_data())
class FirstFrame(Frame):
def __init__(self, master=None, **kwargs):
super().__init__(master, **kwargs)
self.configure(bg="red")
self.grid(row=0, column=0, sticky="nsew")
InventoryLabel(self)
class Window(Tk):
def __init__(self):
super().__init__()
self.geometry("1250x950")
self.title("Inventory")
text_frame = FirstFrame(self)
self.mainloop()
The problem is in the window.
That happens because you're doing self.mainloop() in the class itself, so the other elements doesn't have time to load.
It's like that:
Do that:
And hopefully it would work.
If you want to add the elemnts AFTER the window is created, you can do window.after(1, function)