Open In App

Tkinter – Separator Widget

Last Updated : 15 Oct, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

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:

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 modules
from tkinter import *
from tkinter import ttk
 
 
# Main tkinter window
x = Tk()
x.geometry("400x300")
 
 
# Label Widget
b = 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 object
separator = ttk.Separator(x, orient='vertical')
separator.place(relx=0.47, rely=0, relwidth=0.2, relheight=1)
 
 
# Label Widget
a = 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 modules
from tkinter import *
from tkinter import ttk
 
 
# Main tkinter window
x = Tk()
x.geometry("400x300")
 
 
# Label Widget
b = 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 object
separator = ttk.Separator(x, orient='horizontal')
separator.place(relx=0, rely=0.47, relwidth=1, relheight=1)
 
 
# Label Widget
a = 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:
 

 



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads