开发者

Python 2.7/Windows resizable ttk progressbar?

开发者 https://www.devze.com 2023-01-21 07:07 出处:网络
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 documentati

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'开发者_JS百科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()
0

精彩评论

暂无评论...
验证码 换一张
取 消