views:

30

answers:

1

I'm experimenting with Python 2.7's new Tkinter Tile support (ttk). Is there a way to make the ttk.Progressbar() control auto-resize in proportion to its parent container? In reading the documentation on this control, it appears that one must explicitly set this widget's height or width?

I'm looking for a way to place the ttk.Progressbar widget in a horizontally resizable Tkinter dialog and have this widget resize as a user resize's the parent dialog.

Is there a window or frame resize event that I can trap, a ttk.Progressbar setting I can .config(), or .pack() option I can use to achieve my goal?

Any suggestions appreciated.

+1  A: 

Try using the fill option of pack (or grid) to have the widget fill its container.

import Tkinter as tk
import ttk

root=tk.Tk()
pb = ttk.Progressbar(mode="indeterminate")
pb.pack(side="bottom", fill="x")
pb.start()
root.wm_geometry("300x300")
root.mainloop()
Bryan Oakley
Bryan: Thank you very much for your help (again!). I can see from your example that I was using an incorrect layout technique for my progressbar. BTW: Any specific reason why you chose to use .wm_geometry() vs. .geometry()?
Malcolm
@Malcolm: no reason. Most of my experience with Tk is with Tcl/Tk so I tend to use the constructs that mimic the Tcl implementation out of habit. In Tcl/Tk the command is "wm geometry".
Bryan Oakley
Thank you Bryan.
Malcolm