Align boxes with tkinter

Viewed 25

I'm using tkinter and I'm pretty new. I'm trying to align the left and right red boxes. But i couldn't.

see this picture

my code:

class App(Tk):
    def __init__(self):
        super().__init__()
        s = ttk.Style()
        s.configure("Bg1.TFrame", background="#1e1e1e")
        s.configure("Bg2.TFrame", background="#404040")
        s.configure("Title.TLabel", background="green", foreground="#ddd", font=("Arial", 23, "bold"), padding=(0, 5))
        s.configure("Left.TLabel", background="red", foreground="#ddd", font=("Arial", 10, "bold"), padding=(20, 10), justify=LEFT)
        s.configure("Sfc.TFrame")
    
        self.geometry("900x450")
        self.columnconfigure(0, weight=100, uniform="group1")
        self.columnconfigure(1, weight=1, uniform="group1")
        self.columnconfigure(2, weight=100, uniform="group1")
        self.rowconfigure(0, weight=1)
        
        left_frame = ttk.Frame(self, style="Bg1.TFrame")
        left_frame.grid(row=0, column=0, sticky="NSEW")

        center_frame = ttk.Frame(self, style="Bg2.TFrame")
        center_frame.grid(row=0, column=1, sticky="NSEW")

        right_frame = ttk.Frame(self, style="Bg1.TFrame")
        right_frame.grid(row=0, column=2, sticky="NSEW")
        
        # ----------------------------------------------
        left_frame.columnconfigure(0, weight=1)
        left_frame.rowconfigure(0, weight=1)
        left_frame.rowconfigure(1, weight=7)

        left_frame_title = ttk.Label(left_frame, text="Title", style="Title.TLabel")
        left_frame_title.grid(column=0, row=0, sticky="n")

        txt = ["start:", "end:", "data1:", "data2:"]

        left_content = ttk.Label(left_frame, text="\n".join(txt), style="Left.TLabel")
        left_content.grid(column=0, row=1, sticky="nw")
        
        left_content_c2 = ttk.Label(left_frame, text="\n".join(txt), style=("Left.TLabel"))
        left_content_c2.grid(column=1, row=1, sticky="nw")
        # ----------------------------------------------
        right_frame.columnconfigure(0, weight=1)
        right_frame.rowconfigure(0, weight=1)
        right_frame.rowconfigure(1, weight=10)
        
        right_frame_title = ttk.Label(right_frame, text="Title", style="Title.TLabel")
        right_frame_title.grid(column=0, row=0, sticky="n")
        
        sf = ScrollFrame(right_frame, background="red")
        sf.grid(column=0, row=1, sticky="nsew")
        

App().mainloop()

I usually use the grid() construct. I'm trying to make it responsive with columnconfigure() and rowconfigure().

Thank you

0 Answers
Related