Reputation: 45
I would like to draw tick marks on the side of a progressbar.
example:
from tkinter import *
from tkinter import ttk
root = Tk()
mainframe = ttk.Frame(root, padding="3 3 12 12")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
mainframe.columnconfigure(0, weight=1)
mainframe.rowconfigure(0, weight=1)
TickValue=15
#TickValue=85
ttk.Label(mainframe, text='%2i-' % TickValue).grid(row=1, column=1, sticky=(N,E), pady=(100-TickValue-13))
pbar= ttk.Progressbar(mainframe, value=15, orient=VERTICAL, length=100)
pbar.grid(row=1, column=2, sticky=(N, W))
root.mainloop()
TickValue=85 looks pretty fine, but TickValue=15 seems to push the height of the row to the south. The window has a big and ugly border. How can I prevent that?
(My code is mainly copy-pasted from http://www.tkdocs.com/tutorial/firstexample.html)
Upvotes: 2
Views: 50
Reputation: 76184
The row is increasing in size because, by default, pady
adds padding both above and below the widget. When TickValue
is 15, pady
is 72, for a total cell height of 144 plus however tall the actual label is. You can independently specify the top and bottom padding by passing a two element tuple to the parameter.
Change
pady=(100-TickValue-13)
to
pady=(100-TickValue-13, 0)
Now there should only be top padding, and no bottom padding.
Upvotes: 2