Python 将屏幕大小与当前根窗口大小进行比较

Python 将屏幕大小与当前根窗口大小进行比较,python,tkinter,tk,Python,Tkinter,Tk,我使用tkinter创建GUI。在根窗口中,有一些小部件和画布。用户可以控制画布的大小 我想做的是: 当主根目录的总大小不适合屏幕时,画布将停止扩展(停止变大),并可滚动 问题是: 我不知道如何比较这些值。如何将当前根大小作为整数获取 这是一个好方法还是有更好的解决方案 我尝试的是: root.winfo_screenwidth() and root.winfo_screenheight() #to get Screen size. root.winfo_geometry() or root.

我使用tkinter创建GUI。在根窗口中,有一些小部件和画布。用户可以控制画布的大小

我想做的是: 当主根目录的总大小不适合屏幕时,画布将停止扩展(停止变大),并可滚动

问题是: 我不知道如何比较这些值。如何将当前根大小作为整数获取

这是一个好方法还是有更好的解决方案

我尝试的是:

root.winfo_screenwidth() and root.winfo_screenheight() #to get Screen size.

root.winfo_geometry() or root.geometry() #to get the current size of the root as a string in %sx%s+0+0 format.

您不应该使用
root.geometry()
来解决此问题。请尝试使用
root.winfo_width()
root.winfo_height()

#检查尺寸前的代码
如果root.winfo_width()*root.winfo_height()
您不应该使用
root.geometry()
来解决此问题。请尝试使用
root.winfo_width()
root.winfo_height()

#检查尺寸前的代码
如果root.winfo_width()*root.winfo_height()