Skip to content
Related Articles

Related Articles

Improve Article

Tkinter – Separator Widget

  • Last Updated : 16 Jun, 2021

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 programm 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 programm 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:
 

 

 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




My Personal Notes arrow_drop_up
Recommended Articles
Page :