Tkinter on Ubuntu 14.02 Reports width as sum of both monitors

跟風遠走 提交于 2020-02-02 13:53:37

问题


I have two monitors on a new Ubuntu 14.02 machine. One monitor is 1024X768 VGA. The second monitor is 1920X1080 HDMI No matter what I do root.winfo_screenwidth() reports 2944 (The sum of both monitors) (If I stack the monitors then winfo_screenheight reports the sum of heights)

Of course I did most of the development of my software on Windows where it worked fine (with two monitors)

With only one monitor plugged in to the Ubuntu machine, it works fine.

This all fails very badly with:

import Tkinter

root=Tkinter.Tk()
root.attributes('-fullscreen',True)
root.update()
print root.winfo_screenwidth()
print root.winfo_screenheight()

When Tkinter creates the root window with the -fullscreen attribute, it creates a window that it thinks is way wider than it is. So on my windows machine (with two monitors) root.winfo_screenwidth() is 1680. But on my Ubuntu machine (with two monitors) root.winfo_screenwidth() is 2944.

Help.....


回答1:


Once again the difference between Windows and X I guess.

On Windows: root.winfo_screenwidth() equals the current monitor width.

On X: root.winfo_screenwidth() equals the width of the all monitors. (Props to @tripleee)

root.winfo_width() equals the width of the current display on both X and windows.

Is there a good reference for the diff between windows and X?



来源:https://stackoverflow.com/questions/24377988/tkinter-on-ubuntu-14-02-reports-width-as-sum-of-both-monitors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!