Python窗口学习之监听窗口变化触发函数(Monitor window change trigger function for Python window learning)

在窗口大小发生变化后,往往组件也需要调整

代码:

#空间适应屏幕
        def window_resiz(self,event=None):
            print(window.winfo_height())
            print(window.winfo_width())
# 注册(绑定)窗口变动事件
        window.bind('<Configure>', window_resiz)

不足就是窗口位置变化,也会触发函数

————————

After the window size changes, the components often need to be adjusted

code:

#空间适应屏幕
        def window_resiz(self,event=None):
            print(window.winfo_height())
            print(window.winfo_width())
# 注册(绑定)窗口变动事件
        window.bind('<Configure>', window_resiz)

The disadvantage is that if the window position changes, the function will also be triggered