mirror of
https://github.com/1j01/textual-paint.git
synced 2024-09-11 15:56:03 +03:00
Get screen size properly, with screeninfo module
This commit is contained in:
parent
fd7f3e8fcc
commit
7f3fe53d3e
@ -96,6 +96,7 @@
|
|||||||
"rmam",
|
"rmam",
|
||||||
"rmate",
|
"rmate",
|
||||||
"rubymine",
|
"rubymine",
|
||||||
|
"screeninfo",
|
||||||
"setterm",
|
"setterm",
|
||||||
"setuptools",
|
"setuptools",
|
||||||
"Shft",
|
"Shft",
|
||||||
|
@ -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
|
# 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
|
pyperclip==1.8.2
|
||||||
pyxdg==0.28 # xdg module, used for wallpaper setting; optional, falls back to ~/.config
|
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
|
rich==13.3.5
|
||||||
stransi==0.3.0
|
stransi==0.3.0
|
||||||
textual[dev]==0.27.0
|
textual[dev]==0.27.0
|
||||||
|
@ -3589,10 +3589,18 @@ Columns: {len(palette) // 2}
|
|||||||
self.message_box(_("Paint"), _("Failed to set the wallpaper."), "ok", error=e)
|
self.message_box(_("Paint"), _("Failed to set the wallpaper."), "ok", error=e)
|
||||||
def get_screen_size(self) -> tuple[int, int]:
|
def get_screen_size(self) -> tuple[int, int]:
|
||||||
"""Get the screen size."""
|
"""Get the screen size."""
|
||||||
# TODO: test DPI scaling; implement this without taking a screenshot
|
# TODO: test DPI scaling
|
||||||
import PIL.ImageGrab
|
from screeninfo import get_monitors
|
||||||
im = PIL.ImageGrab.grab()
|
largest_area = 0
|
||||||
return im.size
|
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:
|
def action_recent_file(self) -> None:
|
||||||
self.message_box(_("Paint"), "Not implemented.", "ok")
|
self.message_box(_("Paint"), "Not implemented.", "ok")
|
||||||
|
Loading…
Reference in New Issue
Block a user