From a37fe76f7c1f7ac66fa07ff9c996b7bf61dab1b3 Mon Sep 17 00:00:00 2001 From: Xinyu Chen Date: Sat, 20 Aug 2022 14:25:12 -0700 Subject: [PATCH] Use screeninfo for cross platform --- UVR.py | 28 +++++++++++++++++----------- requirements.txt | 2 +- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/UVR.py b/UVR.py index 1b23ec0d..69c68dc6 100644 --- a/UVR.py +++ b/UVR.py @@ -53,7 +53,13 @@ import urllib.request import pyAesCrypt from __version__ import VERSION -from win32api import GetSystemMetrics +from screeninfo import get_monitors + +def get_screen_resolution(): + monitors = get_monitors() + if len(monitors) == 0: + return 800 + return monitors[0].width try: with open(os.path.join(os.getcwd(), 'tmp', 'splash.txt'), 'w') as f: @@ -463,7 +469,7 @@ class MainWindow(TkinterDnD.Tk): # --Constants-- # Layout - if GetSystemMetrics(1) >= 900: + if get_screen_resolution() >= 900: IMAGE_HEIGHT = 140 FILEPATHS_HEIGHT = 85 OPTIONS_HEIGHT = 275 @@ -471,7 +477,7 @@ class MainWindow(TkinterDnD.Tk): COMMAND_HEIGHT = 200 PROGRESS_HEIGHT = 30 PADDING = 10 - elif GetSystemMetrics(1) <= 720: + elif get_screen_resolution() <= 720: IMAGE_HEIGHT = 135 FILEPATHS_HEIGHT = 85 OPTIONS_HEIGHT = 274 @@ -508,7 +514,7 @@ def __init__(self): height=height, xpad=int(self.winfo_screenwidth()/2 - 635/2), ypad=int(self.winfo_screenheight()/2 - height/2 - 30))) - if GetSystemMetrics(1) >= 900: + if get_screen_resolution() >= 900: pass else: self.tk.call('tk', 'scaling', 1.1) @@ -532,7 +538,7 @@ def __init__(self): size=(30, 30)) self.key_img = open_image(path=key_path, size=(30, 30)) - if GetSystemMetrics(1) >= 900: + if get_screen_resolution() >= 900: self.gen_opt_img = open_image(path=gen_opt_path, size=(900, 826)) self.mdx_opt_img = open_image(path=mdx_opt_path, @@ -547,7 +553,7 @@ def __init__(self): size=(900, 826)) self.credits_img = open_image(path=credits_path, size=(100, 100)) - elif GetSystemMetrics(1) <= 720: + elif get_screen_resolution() <= 720: self.gen_opt_img = open_image(path=gen_opt_path, size=(740, 826)) self.mdx_opt_img = open_image(path=mdx_opt_path, @@ -3960,10 +3966,10 @@ def help(self): Open Help Guide """ top= Toplevel(self) - if GetSystemMetrics(1) >= 900: + if get_screen_resolution() >= 900: window_height = 810 window_width = 1080 - elif GetSystemMetrics(1) <= 720: + elif get_screen_resolution() <= 720: window_height = 640 window_width = 930 else: @@ -4054,7 +4060,7 @@ def close_win(): frame0=Frame(tab7,highlightbackground='red',highlightthicknes=0) frame0.grid(row=0,column=0,padx=0,pady=30) - if GetSystemMetrics(1) >= 900: + if get_screen_resolution() >= 900: l0=tk.Label(frame0,text="Notes",font=("Century Gothic", "16", "bold"), justify="center", fg="#f4f4f4") l0.grid(row=1,column=0,padx=20,pady=10) @@ -5992,10 +5998,10 @@ def error_log(self): Open Error Log """ top= Toplevel(self) - if GetSystemMetrics(1) >= 900: + if get_screen_resolution() >= 900: window_height = 810 window_width = 1080 - elif GetSystemMetrics(1) <= 720: + elif get_screen_resolution() <= 720: window_height = 640 window_width = 930 else: diff --git a/requirements.txt b/requirements.txt index 1b3185dc..1940d8e4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -22,10 +22,10 @@ pyAesCrypt pydub pyglet pyperclip -pywin32 pyyaml resampy==0.2.2 samplerate +screeninfo scipy SoundFile soundstretch