Tkinter PanedWindow

Tkinter PanedWindow is known as a container widget that contains one or more child widgets and can arrange horizontally or vertically. Each pane contains one widget and each pair of panes is separated by a movable sash. By moving a sash causes the widgets on either side of the sash to be resized.

Syntax:

The parameter, master represents the parent window, and options are used to set various attributes as key-values separated by commas. The options are described below:

Options of Tkinter PanedWindow:

bg: It represents the background color of the widget when it doesn’t have the focus.

borderwidth: It shows the width of border. By default is 2.

cursor: It shows the cursor that appears when the mouse is over the window.

sashwidth: By default is 2.

width: This option have no default value.

showhandle: This option shows no default value.

orient:  This option will be set to Horizontal to place the child windows side by side.

sashrelief: This shows the type of the border around each of the sash. By default is FLAT.

sashpad: This option shows the padding to be done around each sash. The default is 0.

height: It represents the height of the widget. If we do not specify the height, it will be calculated by the height of the child window.

bd: It represents the 3D border size of the widget. The default option specifies that the trough contains no border whereas the arrowheads and slider contain the 2-pixel border size.

Methods of Tkinter PanedWindow:

get(startindex [,endindex]): This method returns a specific character.

config(options): This method modifies widget options. If no options are given, It returns a dictionary containing all current option values.

add(child, options): To the paned window, this method adds a child window.

Example:
from tkinter import *

appWindow = Tk()
appWindow.title("Window Title-Tutorialsart.com")

appWindow.geometry('350x200')


def add():
    a = int(e1.get())
    b = int(e2.get())
    leftdata = str(a)+" + "+str(b)+"="+str(+a + b)
    left.insert(1, leftdata)


w1 = PanedWindow()
w1.pack(fill=BOTH, expand=1)

left = Entry(w1, bd=5)
w1.add(left)

w2 = PanedWindow(w1, orient=VERTICAL)
w1.add(w2)

e1 = Entry(w2)
e2 = Entry(w2)

w2.add(e1)
w2.add(e2)

bottom = Button(w2, text="CLICK to Add", command=add)
w2.add(bottom)
appWindow.mainloop()
Output:
16 tkinter pannedwindow

Comments are closed.