- Tkinter GUI Programming by Example
- David Love
- 247字
- 2021-08-27 18:49:07
place
Unlike pack and grid, which automatically calculate where each new widget is added, place can be used in order to specify an exact location for a particular widget. place takes either x and y coordinates (in pixels) to specify an exact spot, which will not change as the window is resized, or relative arguments to its parent, allowing the widget to move with the size of the window.
To place a widget at (5, 10) within the window, you would write widget.place(x=5, y=10).
To keep a widget in the direct center, you would use widget.place(relx=0.5, rely=0.5).
place also takes sizing options, so to keep a widget at 50 percent width and 25 percent height of the window, add (relwidth=0.5, relheight=0.25).
place is rarely used in bigger applications due to its lack of flexibility. It can be tiresome keeping track of exact coordinates for a widget, and as things change with the application, widgets may resize, causing unintended overlapping.
For a smaller window with only one or two widgets – say a custom pop-up message – place could be a viable choice of geometry manager, since it allows for very easy centering of said widgets.
One thing to note is that place can be used alongside pack or grid within the same parent widget. This means that if you have just one widget which you need to put in a certain location, you can do so quickly without having to restructure your already packed or gridded widgets.
- Flask Web全棧開發實戰
- Mobile Application Development:JavaScript Frameworks
- Learning Spring 5.0
- C語言程序設計
- Designing Hyper-V Solutions
- 零基礎學單片機C語言程序設計
- Java EE 8 Application Development
- Apache Spark 2.x for Java Developers
- Swift 4 Protocol-Oriented Programming(Third Edition)
- Mobile Device Exploitation Cookbook
- Mastering Python Design Patterns
- 后臺開發:核心技術與應用實踐
- 自學Python:編程基礎、科學計算及數據分析(第2版)
- 從0到1:HTML5 Canvas動畫開發
- 深入理解BootLoader