how to create a panedWindow in tkinter with three panedwindows as children and the left and right panedwindows having defined width

Viewed 17

Please I am trying to create a UI but I coulld get the main window up and running. I want the left and right paned window to have defined width and the middle should cover remaining width. this is working for the left pane but it is not working for right pane. below is the code and the output. I am just learning tkinter and everything I read from the documentation does not work for me. PLease Is there anyone who could help.

`

import customtkinter
from tkinter import *
import tkinter.messagebox

customtkinter.set_appearance_mode("Dark")  # Modes: "System" (standard), "Dark", "Light"
customtkinter.set_default_color_theme("dark-blue")  # Themes: "blue" (standard), "green", "dark-blue"


def addPage():
    pass


def copyText():
    pass


class App(customtkinter.CTk):
    width = 1440
    height = 1024

    def __init__(self):
        super().__init__()

        self.geometry(f"{App.width}x{App.height}")
        self.radio_var = tkinter.IntVar(value=0)

        ###Menus
        self.myMenu = Menu(self)
        self.config(menu=self.myMenu)
        # File Menu
        self.fileMenu = Menu(self.myMenu)
        self.myMenu.add_cascade(label="File", menu=self.fileMenu)
        self.fileMenu.add_command(label="add...", command=addPage)

        # Edit Menu
        self.editMenu = Menu(self.myMenu)
        self.myMenu.add_cascade(label="Edit", menu=self.editMenu)
        self.editMenu.add_command(label="Copy", command=copyText)

        # define Frames
        self.grid_columnconfigure(0, weight=1)
        self.grid_rowconfigure(0, weight=1)

        self.frameBody = customtkinter.CTkFrame(master=self)
        self.frameBody.grid(row=0, column=0, sticky="nswe")

        self.frameFooter = customtkinter.CTkFrame(master=self, height=25, fg_color="#a6a6a6", corner_radius=0)
        self.frameFooter.grid(row=1, column=0, sticky="nswe")

        # main panel body
        self.paneBody = PanedWindow(self.frameBody)
        self.paneBody.pack(fill="both", expand=True)

        #other three panes
        self.paneLeftBody = PanedWindow(self.paneBody, bg = 'red', width = 300)
        self.paneBody.add(self.paneLeftBody)

        self.paneMiddleBody = PanedWindow(self.paneBody,orient = 'vertical')
        self.paneBody.add(self.paneMiddleBody)

        self.paneRightBody = PanedWindow(self.paneBody, bg = 'black', width = 300)
        self.paneBody.add(self.paneRightBody)

        self.middleTopPane = customtkinter.CTkFrame(self.paneMiddleBody, fg_color='red')
        self.paneMiddleBody.add(self.middleTopPane,sticky="nswe")

        self.middleBottomPane = customtkinter.CTkFrame(self.paneMiddleBody, height=300)
        self.paneMiddleBody.add(self.middleBottomPane)

if __name__ == "__main__":
    app = App()
    app.mainloop()

` Output

0 Answers
Related