Tkinter – Separator Widget
Tkinter supports a variety of widgets to make GUI more and more attractive and functional. The Separator widget is used to partition the tkinter widgets such as label, buttons etc. Using this widget we can make our design more attractive and intuitive. Now we will see how to implement this widget.
Syntax:
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course
Separator(master, orient)
Parameters:
- master: parent widget or main Tk() object
- orient: vertical or horizontal
Below are the programs which depict the use of Separator Widget in Tkinter:
Vertical Orientation:
Python3
# Python program to# Illustrate Separator# widget# Import required modulesfrom tkinter import *from tkinter import ttk# Main tkinter windowx = Tk()x.geometry("400x300")# Label Widgetb = Label(x, bg="#f5f5f5", bd=4, relief=RAISED, text="With Separator")b.place(relx=0.03, rely=0.1, relheight=0.8, relwidth=0.4)# Separator objectseparator = ttk.Separator(x, orient='vertical')separator.place(relx=0.47, rely=0, relwidth=0.2, relheight=1)# Label Widgeta = Label(x, bg="#f5f5f5", bd=4, relief=RAISED, text="With Separator")a.place(relx=0.5, rely=0.1, relheight=0.8, relwidth=0.4)mainloop() |
Output:

In the above program, the vertical without separator output will be generated only. However, a tkinter window without separator looks like this:

Horizontal Orientation:
Python3
# Python program to# Illustrate Separator# widget# Import required modulesfrom tkinter import *from tkinter import ttk# Main tkinter windowx = Tk()x.geometry("400x300")# Label Widgetb = Label(x, bg="#f5f5f5", bd=4, relief=RAISED, text="With Separator")b.place(relx=0.1, rely=0.05, relheight=0.4, relwidth=0.8)# Separator objectseparator = ttk.Separator(x, orient='horizontal')separator.place(relx=0, rely=0.47, relwidth=1, relheight=1)# Label Widgeta = Label(x, bg="#f5f5f5", bd=4, relief=RAISED, text="With Separator")a.place(relx=0.1, rely=0.5, relheight=0.4, relwidth=0.8)mainloop() |
Output:

In the above program, the horizontal without separator output will be generated only. However, a tkinter window without a separator looks like this:



