File size: 12,211 Bytes
54c22e4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
import os
import platform
from screeninfo import get_monitors
from PIL import Image
from PIL import ImageTk
OPERATING_SYSTEM = platform.system()
def get_screen_height():
monitors = get_monitors()
if len(monitors) == 0:
raise Exception("Failed to get screen height")
return monitors[0].height, monitors[0].width
def scale_values(value):
if not SCALE_WIN_SIZE == 1920:
ratio = SCALE_WIN_SIZE/1920 # Approx. 1.3333 for 2K
return value * ratio
else:
return value
SCREEN_HIGHT, SCREEN_WIDTH = get_screen_height()
SCALE_WIN_SIZE = 1920
SCREEN_SIZE_VALUES = {
"normal": {
"credits_img":(100, 100),
## App Size
'IMAGE_HEIGHT': 140,
'FILEPATHS_HEIGHT': 75,
'OPTIONS_HEIGHT': 262,
'CONVERSIONBUTTON_HEIGHT': 30,
'COMMAND_HEIGHT': 141,
'PROGRESS_HEIGHT': 25,
'PADDING': 7,
'WIDTH': 680
},
"small": {
"credits_img":(50, 50),
'IMAGE_HEIGHT': 140,
'FILEPATHS_HEIGHT': 75,
'OPTIONS_HEIGHT': 262,
'CONVERSIONBUTTON_HEIGHT': 30,
'COMMAND_HEIGHT': 80,
'PROGRESS_HEIGHT': 25,
'PADDING': 5,
'WIDTH': 680
},
"medium": {
"credits_img":(50, 50),
## App Size
'IMAGE_HEIGHT': 140,
'FILEPATHS_HEIGHT': 75,
'OPTIONS_HEIGHT': 262,
'CONVERSIONBUTTON_HEIGHT': 30,
'COMMAND_HEIGHT': 115,
'PROGRESS_HEIGHT': 25,
'PADDING': 7,
'WIDTH': 680
},
}
try:
if SCREEN_HIGHT >= 900:
determined_size = SCREEN_SIZE_VALUES["normal"]
elif SCREEN_HIGHT <= 720:
determined_size = SCREEN_SIZE_VALUES["small"]
else:
determined_size = SCREEN_SIZE_VALUES["medium"]
except:
determined_size = SCREEN_SIZE_VALUES["normal"]
image_scale_1, image_scale_2 = 20, 30
class ImagePath():
def __init__(self, base_path):
img_path = os.path.join(base_path, 'gui_data', 'img')
credits_path = os.path.join(img_path, 'credits.png')
donate_path = os.path.join(img_path, 'donate.png')
download_path = os.path.join(img_path, 'download.png')
efile_path = os.path.join(img_path, 'File.png')
help_path = os.path.join(img_path, 'help.png')
key_path = os.path.join(img_path, 'key.png')
stop_path = os.path.join(img_path, 'stop.png')
play_path = os.path.join(img_path, 'play.png')
pause_path = os.path.join(img_path, 'pause.png')
up_img_path = os.path.join(img_path, "up.png")
down_img_path = os.path.join(img_path, "down.png")
left_img_path = os.path.join(img_path, "left.png")
right_img_path = os.path.join(img_path, "right.png")
clear_img_path = os.path.join(img_path, "clear.png")
copy_img_path = os.path.join(img_path, "copy.png")
self.banner_path = os.path.join(img_path, 'UVR-banner.png')
self.efile_img = self.open_image(path=efile_path,size=(image_scale_1, image_scale_1))
self.stop_img = self.open_image(path=stop_path, size=(image_scale_1, image_scale_1))
self.play_img = self.open_image(path=play_path, size=(image_scale_1, image_scale_1))
self.pause_img = self.open_image(path=pause_path, size=(image_scale_1, image_scale_1))
self.help_img = self.open_image(path=help_path, size=(image_scale_1, image_scale_1))
self.download_img = self.open_image(path=download_path, size=(image_scale_2, image_scale_2))
self.donate_img = self.open_image(path=donate_path, size=(image_scale_2, image_scale_2))
self.key_img = self.open_image(path=key_path, size=(image_scale_2, image_scale_2))
self.up_img = self.open_image(path=up_img_path, size=(image_scale_2, image_scale_2))
self.down_img = self.open_image(path=down_img_path, size=(image_scale_2, image_scale_2))
self.left_img = self.open_image(path=left_img_path, size=(image_scale_2, image_scale_2))
self.right_img = self.open_image(path=right_img_path, size=(image_scale_2, image_scale_2))
self.clear_img = self.open_image(path=clear_img_path, size=(image_scale_2, image_scale_2))
self.copy_img = self.open_image(path=copy_img_path, size=(image_scale_2, image_scale_2))
self.credits_img = self.open_image(path=credits_path, size=determined_size["credits_img"])
def open_image(self, path: str, size: tuple = None, keep_aspect: bool = True, rotate: int = 0) -> ImageTk.PhotoImage:
"""
Open the image on the path and apply given settings\n
Paramaters:
path(str):
Absolute path of the image
size(tuple):
first value - width
second value - height
keep_aspect(bool):
keep aspect ratio of image and resize
to maximum possible width and height
(maxima are given by size)
rotate(int):
clockwise rotation of image
Returns(ImageTk.PhotoImage):
Image of path
"""
img = Image.open(path).convert(mode='RGBA')
ratio = img.height/img.width
img = img.rotate(angle=-rotate)
if size is not None:
size = (int(size[0]), int(size[1]))
if keep_aspect:
img = img.resize((size[0], int(size[0] * ratio)), Image.ANTIALIAS)
else:
img = img.resize(size, Image.ANTIALIAS)
return ImageTk.PhotoImage(img)
#All Sizes Below Calibrated to 1080p!
if OPERATING_SYSTEM=="Darwin":
FONT_SIZE_F1 = 13
FONT_SIZE_F2 = 11
FONT_SIZE_F3 = 12
FONT_SIZE_0 = 9
FONT_SIZE_1 = 11
FONT_SIZE_2 = 12
FONT_SIZE_3 = 13
FONT_SIZE_4 = 14
FONT_SIZE_5 = 15
FONT_SIZE_6 = 17
HELP_HINT_CHECKBOX_WIDTH = 13
MDX_CHECKBOXS_WIDTH = 14
VR_CHECKBOXS_WIDTH = 14
ENSEMBLE_CHECKBOXS_WIDTH = 18
DEMUCS_CHECKBOXS_WIDTH = 14
DEMUCS_PRE_CHECKBOXS_WIDTH = 20
GEN_SETTINGS_WIDTH = 17
MENU_COMBOBOX_WIDTH = 16
MENU_OPTION_WIDTH = 12
READ_ONLY_COMBO_WIDTH = 35
SETTINGS_BUT_WIDTH = 19
VR_BUT_WIDTH = 16
SET_MENUS_CHECK_WIDTH = 12
COMBO_WIDTH = 14
SET_VOC_SPLIT_CHECK_WIDTH = 21
elif OPERATING_SYSTEM=="Linux":
HELP_HINT_CHECKBOX_WIDTH = 15
MDX_CHECKBOXS_WIDTH = 16
VR_CHECKBOXS_WIDTH = 16
ENSEMBLE_CHECKBOXS_WIDTH = 20
DEMUCS_CHECKBOXS_WIDTH = 16
DEMUCS_PRE_CHECKBOXS_WIDTH = 24
GEN_SETTINGS_WIDTH = 20
MENU_COMBOBOX_WIDTH = 18
MENU_OPTION_WIDTH = 12
READ_ONLY_COMBO_WIDTH = 40
SETTINGS_BUT_WIDTH = 23
VR_BUT_WIDTH = 18
SET_MENUS_CHECK_WIDTH = 13
COMBO_WIDTH = 16
SET_VOC_SPLIT_CHECK_WIDTH = 25
FONT_SIZE_F1 = 10
FONT_SIZE_F2 = 8
FONT_SIZE_F3 = 9
FONT_SIZE_0 = 7
FONT_SIZE_1 = 8
FONT_SIZE_2 = 9
FONT_SIZE_3 = 10
FONT_SIZE_4 = 11
FONT_SIZE_5 = 13
FONT_SIZE_6 = 15
elif OPERATING_SYSTEM=="Windows":
HELP_HINT_CHECKBOX_WIDTH = 15
MDX_CHECKBOXS_WIDTH = 14
VR_CHECKBOXS_WIDTH = 14
ENSEMBLE_CHECKBOXS_WIDTH = 20
DEMUCS_CHECKBOXS_WIDTH = 14
DEMUCS_PRE_CHECKBOXS_WIDTH = 20
GEN_SETTINGS_WIDTH = 18
MENU_COMBOBOX_WIDTH = 16
MENU_OPTION_WIDTH = 12
READ_ONLY_COMBO_WIDTH = 35
SETTINGS_BUT_WIDTH = 20
VR_BUT_WIDTH = 16
SET_MENUS_CHECK_WIDTH = 13
COMBO_WIDTH = 14
SET_VOC_SPLIT_CHECK_WIDTH = 23
FONT_SIZE_F1 = 10
FONT_SIZE_F2 = 8
FONT_SIZE_F3 = 9
FONT_SIZE_0 = 7
FONT_SIZE_1 = 8
FONT_SIZE_2 = 9
FONT_SIZE_3 = 10
FONT_SIZE_4 = 11
FONT_SIZE_5 = 13
FONT_SIZE_6 = 15
#Main Size Values:
IMAGE_HEIGHT = determined_size["IMAGE_HEIGHT"]
FILEPATHS_HEIGHT = determined_size["FILEPATHS_HEIGHT"]
OPTIONS_HEIGHT = determined_size["OPTIONS_HEIGHT"]
CONVERSIONBUTTON_HEIGHT = determined_size["CONVERSIONBUTTON_HEIGHT"]
COMMAND_HEIGHT = determined_size["COMMAND_HEIGHT"]
PROGRESS_HEIGHT = determined_size["PROGRESS_HEIGHT"]
PADDING = determined_size["PADDING"]
WIDTH = determined_size["WIDTH"]
# IMAGE_HEIGHT = 140
# FILEPATHS_HEIGHT = 75
# OPTIONS_HEIGHT = 262
# CONVERSIONBUTTON_HEIGHT = 30
# COMMAND_HEIGHT = 141
# PROGRESS_HEIGHT = 25
# PADDING = 7
# WIDTH = 680
MENU_PADDING_1 = 3
MENU_PADDING_2 = 10
MENU_PADDING_3 = 15
MENU_PADDING_4 = 3
#Main Frame Sizes
X_CONVERSION_BUTTON_1080P = 50
WIDTH_CONVERSION_BUTTON_1080P = -100
HEIGHT_GENERIC_BUTTON_1080P = 35
X_STOP_BUTTON_1080P = -10 - 35
X_SETTINGS_BUTTON_1080P = -670
X_PROGRESSBAR_1080P = 25
WIDTH_PROGRESSBAR_1080P = -50
X_CONSOLE_FRAME_1080P = 15
WIDTH_CONSOLE_FRAME_1080P = -30
HO_S = 7
#File Frame Sizes
FILEPATHS_FRAME_X = 10
FILEPATHS_FRAME_Y = 155
FILEPATHS_FRAME_WIDTH = -20
MUSICFILE_BUTTON_X = 0
MUSICFILE_BUTTON_Y = 5
MUSICFILE_BUTTON_WIDTH = 0
MUSICFILE_BUTTON_HEIGHT = -5
MUSICFILE_ENTRY_X = 7.5
MUSICFILE_ENTRY_WIDTH = -50
MUSICFILE_ENTRY_HEIGHT = -5
MUSICFILE_OPEN_X = -45
MUSICFILE_OPEN_Y = 160
MUSICFILE_OPEN_WIDTH = 35
MUSICFILE_OPEN_HEIGHT = 33
SAVETO_BUTTON_X = 0
SAVETO_BUTTON_Y = 5
SAVETO_BUTTON_WIDTH = 0
SAVETO_BUTTON_HEIGHT = -5
SAVETO_ENTRY_X = 7.5
OPEN_BUTTON_X = 427.1
OPEN_BUTTON_WIDTH = -427.4
SAVETO_ENTRY_WIDTH = -50
SAVETO_ENTRY_HEIGHT = -5
SAVETO_OPEN_X = -45
SAVETO_OPEN_Y = 197.5
SAVETO_OPEN_WIDTH = 35
SAVETO_OPEN_HEIGHT = 32
#Main Option menu
OPTIONS_FRAME_X = 10
OPTIONS_FRAME_Y = 250
OPTIONS_FRAME_WIDTH = -20
FILEONE_LABEL_X = -28
FILEONE_LABEL_WIDTH = -38
FILETWO_LABEL_X = -32
FILETWO_LABEL_WIDTH = -20
TIME_WINDOW_LABEL_X = -43
TIME_WINDOW_LABEL_WIDTH = 0
INTRO_ANALYSIS_LABEL_X = -83
INTRO_ANALYSIS_LABEL_WIDTH = -50
INTRO_ANALYSIS_OPTION_X = -68
DB_ANALYSIS_LABEL_X = 62
DB_ANALYSIS_LABEL_WIDTH = -34
DB_ANALYSIS_OPTION_X = 86
WAV_TYPE_SET_LABEL_X = -43
WAV_TYPE_SET_LABEL_WIDTH = 0
ENTRY_WIDTH = 222
# Constants for the ensemble_listbox_Frame
ENSEMBLE_LISTBOX_FRAME_X = -25
ENSEMBLE_LISTBOX_FRAME_Y = -20
ENSEMBLE_LISTBOX_FRAME_WIDTH = 0
ENSEMBLE_LISTBOX_FRAME_HEIGHT = 67
# Constants for the ensemble_listbox_scroll
ENSEMBLE_LISTBOX_SCROLL_X = 195
ENSEMBLE_LISTBOX_SCROLL_Y = -20
ENSEMBLE_LISTBOX_SCROLL_WIDTH = -48
ENSEMBLE_LISTBOX_SCROLL_HEIGHT = 69
# Constants for Radio Buttons
RADIOBUTTON_X_WAV = 457
RADIOBUTTON_X_FLAC = 300
RADIOBUTTON_X_MP3 = 143
RADIOBUTTON_Y = -5
RADIOBUTTON_WIDTH = 0
RADIOBUTTON_HEIGHT = 6
MAIN_ROW_Y_1 = -15
MAIN_ROW_Y_2 = -17
MAIN_ROW_X_1 = -4
MAIN_ROW_X_2 = 21
MAIN_ROW_2_Y_1 = -15
MAIN_ROW_2_Y_2 = -17
MAIN_ROW_2_X_1 = -28
MAIN_ROW_2_X_2 = 1
LOW_MENU_Y_1 = 18
LOW_MENU_Y_2 = 16
SUB_ENT_ROW_X = -2
MAIN_ROW_WIDTH = -53
MAIN_ROW_ALIGN_WIDTH = -86
CHECK_BOX_Y = 0
CHECK_BOX_X = 20
CHECK_BOX_WIDTH = -49
CHECK_BOX_HEIGHT = 2
LEFT_ROW_WIDTH = -10
LABEL_HEIGHT = -5
OPTION_HEIGHT = 8
LABEL_X_OFFSET = -28
LABEL_WIDTH = -38
ENTRY_WIDTH = 179.5
ENTRY_OPEN_BUTT_WIDTH = -185
ENTRY_OPEN_BUTT_X_OFF = 405
UPDATE_LABEL_WIDTH = 35 if OPERATING_SYSTEM == 'Linux' else 32
HEIGHT_CONSOLE_FRAME_1080P = COMMAND_HEIGHT + HO_S
LOW_MENU_Y = LOW_MENU_Y_1, LOW_MENU_Y_2
MAIN_ROW_Y = MAIN_ROW_Y_1, MAIN_ROW_Y_2
MAIN_ROW_X = MAIN_ROW_X_1, MAIN_ROW_X_2
MAIN_ROW_2_Y = MAIN_ROW_2_Y_1, MAIN_ROW_2_Y_2
MAIN_ROW_2_X = MAIN_ROW_2_X_1, MAIN_ROW_2_X_2
LABEL_Y = MAIN_ROW_Y[0]
ENTRY_Y = MAIN_ROW_Y[1]
BUTTON_Y_1080P = IMAGE_HEIGHT + FILEPATHS_HEIGHT + OPTIONS_HEIGHT - 8 + PADDING*2
HEIGHT_PROGRESSBAR_1080P = PROGRESS_HEIGHT
Y_OFFSET_PROGRESS_BAR_1080P = IMAGE_HEIGHT + FILEPATHS_HEIGHT + OPTIONS_HEIGHT + CONVERSIONBUTTON_HEIGHT + COMMAND_HEIGHT + PADDING*4
Y_OFFSET_CONSOLE_FRAME_1080P = IMAGE_HEIGHT + FILEPATHS_HEIGHT + OPTIONS_HEIGHT + CONVERSIONBUTTON_HEIGHT + PADDING + X_PROGRESSBAR_1080P
LABEL_Y_OFFSET = MAIN_ROW_Y[0]
ENTRY_X_OFFSET = SUB_ENT_ROW_X
ENTRY_Y_OFFSET = MAIN_ROW_Y[1]
OPTION_WIDTH = MAIN_ROW_ALIGN_WIDTH
|