I'm closing in on the screen width/height, at least.


In odd screen sizes or multi-monitor situations,
I make the best guess,
but allow the user to alter things,
via preferences.

No complaints in 10 years.
So there's that.


# For MacOS Code:
import AppKit [(screen.frame().size.width, screen.frame().size.height) for 
screen in AppKit.NSScreen.screens()]

$ For Windows Code:
from win32api import GetSystemMetrics print("Width =", GetSystemMetrics(0)) 
print("Height =", GetSystemMetrics(1))

# QT Code
from PySide import QtGui
dw=QtGui.QDesktopWidget()
dw.screenGeometry()
dw.availableGeometry() # this is a sub rect of screenGeometry because it e.g. 
ignores the space occupied by the task bar on Windows


# GDK, GTK

from gi.repository import Gdk
s = Gdk.Screen.get_default()
print(s.get_width())
print(s.get_height())

# ----------------------

from gi.repository import Gdk, Gtk

# Replace w with the GtkWindow of your application
w = Gtk.Window()
# Get the screen from the GtkWindow
s = w.get_screen()
# Using the screen of the Window, the monitor it's on can be identified
m = s.get_monitor_at_window(s.get_active_window())
# Then get the geometry of that monitor
monitor = s.get_monitor_geometry(m)
# This is an example output
print("Height: %s, Width: %s" % (monitor.height, monitor.width))





-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to