Skip to content
Related Articles

Related Articles

Tkinter – Separator Widget
  • Last Updated : 12 Nov, 2020

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

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)
  
  
# Seperator 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 Seperator")
a.place(relx=0.5, rely=0.1, relheight=0.8, relwidth=0.4)
  
  
mainloop()

chevron_right


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

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)
  
  
# Seperator 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 Seperator")
a.place(relx=0.1, rely=0.5, relheight=0.4, relwidth=0.8)
  
  
mainloop()

chevron_right


Output:

In the above program, the horizontal without separator output will be generated only. However, a tkinter window without 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.

My Personal Notes arrow_drop_up
Recommended Articles
Page :