I am currently working on a project using the customtkinter library. The complexity of the project has grown to a point where I'm having trouble locating the widgets. To address this, I plan to organize the widgets by importing them from a dedicated "widgets" folder. This way, I can use statements like "from widgets import button, entry" to manage them more effectively.
Here is main.py file
import customtkinter as ctk
class App(ctk.CTk):
def __init__(self):
super().__init__()
self.length = 13
self.title("my app")
self.geometry("505x585")
ctk.set_appearance_mode("Dark")
if __name__ == "__main__":
app = App()
app.mainloop()
I tried to make this but it's working.
import customtkinter as ctk
from widgets.button import Button
class App(ctk.CTk):
def __init__(self):
super().__init__()
self.length = 13
self.title("my app")
self.geometry("505x585")
ctk.set_appearance_mode("Dark")
# Button Widget
self.btn = Button(master=self, text='Hi')
self.btn.place(relx=0.5, rely=0.5)
if __name__ == "__main__":
app = App()
app.mainloop()
Here is my button.py
file placed in widgets folder.
from customtkinter import CTkButton
class Button:
def __init__(self):
self.button = CTkButton(
text="Hmm",
)
Furthermore, my aim is to assign default values to each widget. In cases where I don't provide specific arguments within the main file for the widget instances, these widgets will seamlessly adopt the predefined default values.