Basics of Python Tkinter
PanedWindow is a container allowing user to adjust the size by using the mouse. It takes orientation as Horizontal or vertical. By dragging the movable border known as sash we can adjust the width or height ( based on orientation ) of the available space for widgets inside pane.

Tkinter Panedwindow container to manage the pane size by mouse dragging of sash with handle
import tkinter as tk

my_w = tk.Tk()

my_w.title("")  # Adding a title

my_pw = tk.PanedWindow(orient=tk.HORIZONTAL)
#my_pw = tk.PanedWindow(orient=tk.VERTICAL)
b1 = tk.Button(my_w,text='I am at left',font=font1) 
b2 = tk.Button(my_w,text='I am at right ',font=font1) 



Options of PanedWindow
backgroundBackground colour of the pane.
bdWidth of the border, give a different Background colour to check.
bgSame as background ( above ).
borderwidthIn pixel with of the border
cursorShape of the cursor while moving over the panes. ( List of cursor shapes )
To check remove the widgets from pane and watch the cursor shape
handlepadDistance of the handle from top ( Horizontal orientation ) or from Left ( Vertical orient)
handlesizeside length of a sash handle ( handle is square shaped )
heightHeight of the pane in pixel. ( depends on widgets size )
opaqueresizeTrue | False, Resizing of pane is done when mouse button is released.
orient HORIZONTAL | VERTICAL values we can assign.
proxybackgroundBackground colour while drawing the proxy ( related to opaqueresize )
proxyborderwidth Width of the proxy border ( related to opaqueresize ).
proxyrelief flat , relief to use while drawing proxy. ( All type of values for relief )
relief type of relief for the pane ( All type of values for relief )
sashcursorCursor shape when mouse is over the sash ( list of cursor shapes are here )
sashpad Padding from the shash
sashrelief type of the relief for the sash ( All type of values for relief )
sashwidth width of the sash
showhandleFalse | True, to show the handle or not.
widthWidth of the pane in pixel.
proxy Options of PanedWindow

The default option values for panedwindow

List is here .
background: SystemButtonFace
bd: 1
bg: SystemButtonFace
borderwidth: 1
handlepad: 8
handlesize: 8
opaqueresize: 1
orient: horizontal
proxyborderwidth: 2
proxyrelief: flat
relief: flat
sashpad: 0
sashrelief: flat
sashwidth: 3
showhandle: 0
How to get all options and its values ? ( use config() )
for options in my_pd.config():
    print(options + ": " + str(my_pw[options]))
How to set the value for options is here .
my_pw = tk.PanedWindow(orient=tk.HORIZONTAL,bg='yellow',

More than two widgets in PanedWindow

Here we will go for VERTICAL orientation and use some more options like hight.
Here we are including three buttons inside our PanedWindow. We will also include one Label inside the PanedWindow and one at right ( outside ) of the PanedWindow.
import tkinter as tk
my_w = tk.Tk()
my_w.title("")  # Adding a title

my_pw = tk.PanedWindow(orient=tk.VERTICAL,height=180)

l1 = tk.Label(my_w,text='Welcome ( Label )',width=20,bg='lightblue')
b1 = tk.Button(my_w,text='I am at top',width=20,bg='lightgreen') 
b2 = tk.Button(my_w,text='I am at middle',width=20,bg='yellow') 
b3 = tk.Button(my_w,text='I am at bottom',width=20,bg='lightyellow') 
l4= tk.Label(my_w,text='Outside PanedWindow',bg='orange')

my_pw.add(l1) # include label in PanedWindow
my_pw.add(b1) # include button in PandWindow 
my_pw.add(b2) # incldue 2nd button 
my_pw.add(b3) # 3rd button  added. 


Example 1

PanedWindow layout
import tkinter as tk
from tkinter import *
my_w = tk.Tk()

my_h = tk.PanedWindow(my_w, orient=tk.HORIZONTAL)
my_h.pack(side=TOP,fill=BOTH,expand=True) # fill the full space
#One label is added to my_h
my_h.add(tk.Label(my_h, text='  I am at Left ',bg='lightblue'))

#Create one more pane my_v 
#this pane is the child of my_h ( not the child of root my_w)
my_v = tk.PanedWindow(my_h, orient=tk.VERTICAL,bg='lightgreen')
my_v.add(tk.Label(my_v, text='I am at top ',height=5,bg='lightyellow'))
my_v.add(tk.Label(my_v, text='I am at center '))
my_h.add(my_v) # added to main pane my_h

Text Button Entry
Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net

    Post your comments , suggestion , error , requirements etc here

    Python Video Tutorials
    Python SQLite Video Tutorials
    Python MySQL Video Tutorials
    Python Tkinter Video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2022 All rights reserved worldwide Privacy Policy Disclaimer