tkinter ttk separator won't display

The separator has a natural width of 1 pixel. You told it to reserve the space across five columns, but you haven't requested that the separator actually fill those five columns. To solve this, supply the sticky attribute, which says "if there's more space than needed for this widget, make the edges of the widget "stick" to specific sides of its container".

In this case, you want the separator to sticky to the left and right edges of it's container. The sticky attributes uses the points of the compass for values, so you want "e" for east, and "w" for west:

ttk.Separator(...).grid(..., sticky="ew")

@Bryan's sticky solution is fine but it only solves part of the case, since the separator will not cover the entire horizontal width (that you asked). Here is an alternative solution that you can apply: Instead of .grid(), use place() layout and have full control of the position, the width (length) and even the height of the separator. To just apply this to the present case (w/o any extra feature) and cover the full horizontal width, just:

Replace

ttk.Separator(root,orient=HORIZONTAL).grid(row=2, columnspan=5)

with

ttk.Separator(root).place(x=0, y=26, relwidth=1)

You can set 'y' as you like. Also note that orient=HORIZONTAL is not needed since it's the default option. (Check http://effbot.org/tkinterbook/place.htm for details and examples of the use of `.option()' layout.)


You probably have to give the Separator an ipadx so that it will be visible. In your case it is visible but you can't see it because of it's width. Try this:

Separator(root, orient=HORIZONTAL).grid(row=1,column=0,columnspan=4, ipadx=100) 

Tags:

Tkinter

Ttk