In this tutorial, we will learn about Python Tkinter PanedWindow. Tkinter PanedWindow is a widget which is used as a container. A PanedWindow can contain one or more child Panes arranged horizontally or vertically.
Page Contents
Here each pane can contain a widget. The movable (via mouse movements) line to divide between two panes is known as a sash.
Syntax to add Python Tkinter PanedWindow:
w = PanedWindow( master, option)
- master: This represents the parent window.
- options: Here is the list of most commonly used options for this widget.
Example Program of Python Tkinter PannedWindow:
from tkinter import *
mainWindow = Tk()
mainWindow.title("PanedWindow Example")
mainWindow.geometry('350x200')
bigPannedWindow = PanedWindow(mainWindow, orient=HORIZONTAL)
bigPannedWindow.pack(fill=BOTH, expand=1)
label = Label(bigPannedWindow, text="This is left pane", bg="red")
bigPannedWindow.add(label)
rightPannedWindow = PanedWindow(bigPannedWindow, orient=VERTICAL)
bigPannedWindow.add(rightPannedWindow)
topPane = Label(rightPannedWindow, text="This is top pane", bg="blue")
rightPannedWindow.add(topPane)
bottomPane = Label(rightPannedWindow, text="This is bottom pane",bg="orange")
rightPannedWindow.add(bottomPane)
mainWindow.mainloop()
Various possible options in Python Tkinter PanedWindow:
OPTION | DESCRIPTION |
---|---|
bg | This option is used to set the background colour of the widget. |
bd | This option is used to set the size of the 3D border around the widget. |
borderwidth | This option is used to set the width of the border. By default, it is 2px. |
cursor | This option used to set the style of cursor like an arrow, dot etc |
handlepad | This option is used to set the distance between the handle and the end of the sash. In the case of horizontal orientation, it is used to set the distance between the top of the sash and the handle. By default this distance is 8px. |
handlesize | This option is used to set the size of the handle. By default, it is 8px. |
height | This used to set the height of the widget. |
orient | This option is used to set the orientation of the PanedWindow. |
relief | This used to set the type of the widget. |
sashpad | This option is used to set the padding around each sash. |
sashrelief | This option is used to set a border around the sash. By default, it is FLAT. |
sashwidth | This option is used to set the width of the sash. By default, it is 2px. |
showhandle | This option is used to control the visibility of handle. By default, it is false. |
width | This option is used to set the width of the widget. |
Tkinter PanedWindow Methods:
After learning about various available options in Python Tkinter PanedWindow. Its time to check out some available methods for Python Tkinter PanedWindow widget.
METHODS | DESCRIPTION |
---|---|
add(child, options) | This method is used to add a child widget to the PanedWindow. |
get(startindex [,endindex]) | This method is used to get the text between the specified range. |
config(options) | This method is used to configure the widget with specified options. |