I'm starting to build an application for automated network troubleshooting. It's going without any issues so far. I'm using an OOP approach @ which i create the widgets in the init method. what's bothering me is that when the application starts getting more complex (Ex: Adding way more widgets); the init method will get more crowded limiting the visibility of the code.
Is there a better way to create the widgets without crowding the init() method?
from tkinter import *
import customtkinter
class App(customtkinter.CTk):
def __init__(self):
super().__init__()
self.title("Automated TShooting Application")
self.geometry("587x450+500+50")
self.iconbitmap("Sharingan.ico")
self.resizable(False, False)
self.mainframe = customtkinter.CTkFrame(self, width=400, height=400)
self.mainframe.grid(row=0, column=0, padx=20, pady=(20, 20))
self.username_label = customtkinter.CTkLabel(self.mainframe, text="Username")
self.username_label.grid(row=0, column=0, padx=20, pady=(20, 0))
self.username_entry = customtkinter.CTkEntry(self.mainframe)
self.username_entry.grid(row=1, column=0, padx=20)
self.password_label = customtkinter.CTkLabel(self.mainframe, text="Password")
self.password_label.grid(row=2, column=0)
self.password_entry = customtkinter.CTkEntry(self.mainframe)
self.password_entry.grid(row=3, column=0, padx=20, pady=(0, 20))
if __name__ == "__main__":
customtkinter.set_appearance_mode("light")
app = App()
app.mainloop()