Tkinter on Ubuntu 14.02 Reports width as sum of both monitors
Asked Answered
M

1

2

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.....

Marsh answered 24/6, 2014 at 3:44 Comment(2)
This is how a workspace spanning dual monitors is commonly set up on X. If you want "full screen" then covering all the area of the display is a rather universal interpretation of what that means. If you mean something else, work out what exactly you mean; expressing that in code should then hopefully be straightforward.Ecosystem
It does NOT cover the entire screen space (Both monitors). The -fullscreen attribute creates a window on ONE monitor that is logically as wide as both. It DOES NOT span monitors it is clipped. Is there another way to do this?Marsh
M
3

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?

Marsh answered 24/6, 2014 at 19:10 Comment(1)
On Windows, winfo_vrootwidth() returns the total width of all monitors.Styptic

© 2022 - 2024 — McMap. All rights reserved.