到目前為止,我發現了四個與寬度(或高度)相關的小部件的方法和屬性(其中一些也可用于獲取其他小部件屬性)。它們之間有什么區別?
widget["width"]widget.cget("width")widget.winfo_width()widget.winfo_reqwidth()
(對于高度也有等效的方法和屬性)。
uj5u.com熱心網友回復:
- 第一個( widget["width"]) 是just a wrapping其他一些命令,如果不反編譯該函式,我無法告訴您是哪個命令。
-第二個( widget. cget("width"))是width using the access to widget object通過物件的getters方法訪問變數的方法
-第三個(widget.winfo_width())可以用來知道當前width asking to TK's windows manager
-第四個 ( widget.winfo_reqwidth()) 可以告訴您width小部件originally打開時的大小,or anyway before the widget.update_idletasks () method.
一般來說,我們可以說all do the same thing but,正如您所猜測的,在這種情況下,subtle differences它們允許您to access the information you are looking for differentlywidth
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/393601.html
