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",
|
||||
"rmate",
|
||||
"rubymine",
|
||||
"screeninfo",
|
||||
"setterm",
|
||||
"setuptools",
|
||||
"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
|
||||
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
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user