I'm trying to display my frame in my window but for some reason its giving me a blank window. It's my first time using classes with tkinter do i need to call it in the object?
from customtkinter import *
class app(CTk):
def __init__(self, title, size):
# main setup
super().__init__()
self.title(title)
self.geometry(f'{size[0]}x{size[1]}')
self.minsize(size[0],size[1])
# widget
self.menu = CTkFrame(self)
# run
self.mainloop()
class Menu(CTkFrame):
def __init__(self, parent):
super().__init__(parent)
self.place(x=0,y=0, relwidth = 0.3, relheight = 1)
self.create_widgets()
def create_widgets(self):
heading_var = StringVar(value="Ethan")
def heading_combo(choice):
print(choice)
heading = CTkComboBox(self, value=["Ethan","Brock", "Liam"], command=heading_combo,variable=heading_var)
self.columnconfigure((0,1,2),weight=1, uniform='a')
self.rowconfigure((0,1,2,3,4),weight=1, uniform='a')
heading.pack()
app('Scoring Software', (600,600))
You are getting a blank window because you didn't call a
pack(),grid()orplace()method on the self.menu widget.To fix this you can add
self.menu.pack()on line 13. The full code is the following:But your code seems weird, you are creating a Menu class but not using it.
If you thought doing this
class Menu(CTkFrame):would completly overwrite the CTkFrame class, you are wrong, it just creates a new class with modified methods.To use the Menu class you created, you should replace the 12th line by this:
Hope I helped you, have a nice day