Get screen size properly, with screeninfo module

This commit is contained in:
Isaiah Odhner 2023-07-17 23:35:20 -04:00
parent fd7f3e8fcc
commit 7f3fe53d3e
3 changed files with 14 additions and 4 deletions

View File

@ -96,6 +96,7 @@
"rmam",
"rmate",
"rubymine",
"screeninfo",
"setterm",
"setuptools",
"Shft",

View File

@ -5,6 +5,7 @@ pyfiglet==0.8.post1
# PyGObject==3.42.1 # gi.repository module, used for setting the wallpaper on gnome, unity, and cinnamon; optional, falls back to gsettings CLI
pyperclip==1.8.2
pyxdg==0.28 # xdg module, used for wallpaper setting; optional, falls back to ~/.config
screeninfo==0.8.1 # used for wallpaper setting
rich==13.3.5
stransi==0.3.0
textual[dev]==0.27.0

View File

@ -3589,10 +3589,18 @@ Columns: {len(palette) // 2}
self.message_box(_("Paint"), _("Failed to set the wallpaper."), "ok", error=e)
def get_screen_size(self) -> tuple[int, int]:
"""Get the screen size."""
# TODO: test DPI scaling; implement this without taking a screenshot
import PIL.ImageGrab
im = PIL.ImageGrab.grab()
return im.size
# TODO: test DPI scaling
from screeninfo import get_monitors
largest_area = 0
largest_monitor = None
for m in get_monitors():
area = m.width * m.height
if area > largest_area:
largest_area = area
largest_monitor = m
assert largest_monitor is not None, "No monitors found."
return largest_monitor.width, largest_monitor.height
def action_recent_file(self) -> None:
self.message_box(_("Paint"), "Not implemented.", "ok")