문제

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.

도움이 되었습니까?

해결책

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()
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top