mirror of
https://github.com/1j01/textual-paint.git
synced 2024-08-17 03:40:26 +03:00
Get screen size with tkinter instead
screeninfo caused a bouncing python rocket in the dock on mac, and didn't work.
This commit is contained in:
parent
7f3fe53d3e
commit
eb0f781ca8
@ -224,6 +224,8 @@ GNOME Terminal works best, with crisp triangles used for icons in dialogs, emoji
|
||||
|
||||
### macOS
|
||||
|
||||
For **Set As Wallpaper**, it works better if you install tkinter, with `brew install python-tk`, so it can use your monitor's resolution. (This dependency could be removed in the future.)
|
||||
|
||||
Tested on OSX 10.14 (Mojave), with iTerm2, and VS Code's integrated terminal.
|
||||
|
||||
iTerm2 mostly works, but two tool icons are missing (Free-Form Select and Fill With Color).
|
||||
|
@ -109,6 +109,7 @@
|
||||
"textconv",
|
||||
"thumbnailer",
|
||||
"Thunar",
|
||||
"tkinter",
|
||||
"tlaplus",
|
||||
"truecolor",
|
||||
"tspan",
|
||||
|
@ -5,7 +5,6 @@ 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
|
||||
|
@ -3590,17 +3590,25 @@ Columns: {len(palette) // 2}
|
||||
def get_screen_size(self) -> tuple[int, int]:
|
||||
"""Get the screen 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
|
||||
try:
|
||||
# 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
|
||||
|
||||
import tkinter
|
||||
root = tkinter.Tk()
|
||||
root.withdraw()
|
||||
return root.winfo_screenwidth(), root.winfo_screenheight()
|
||||
except Exception as e:
|
||||
print("Failed to get screen size:", e)
|
||||
return 1920, 1080
|
||||
|
||||
def action_recent_file(self) -> None:
|
||||
self.message_box(_("Paint"), "Not implemented.", "ok")
|
||||
|
Loading…
Reference in New Issue
Block a user