-
Notifications
You must be signed in to change notification settings - Fork 0
/
RealESRGAN-GUI.py
46 lines (35 loc) · 1.3 KB
/
RealESRGAN-GUI.py
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
import gettext
import locale
import os
import platform
import tkinter as tk
from RealESRGAN import RealESRGAN
if platform.system() == 'Windows':
os.environ['LANGUAGE'] = locale.getdefaultlocale()[0]
gettext.install(domain='RealESRGAN_GUI', localedir='locale')
class RealESRGANGui(tk.Tk):
def __init__(self):
super(RealESRGANGui, self).__init__()
self.title('RealESRGAN GUI')
self.iconphoto(False, tk.PhotoImage(file='realesrgan.png'))
RealESRGAN(self).pack()
self._center()
def _center(self):
screen_width = self.winfo_screenwidth()
screen_height = self.winfo_screenheight()
window_width = screen_width * 1 // 2
window_height = screen_height * 2 // 3
screen_height = screen_height * 4 // 5
left = (screen_width - window_width) // 2
top = (screen_height - window_height) // 2
self.wm_minsize(window_width, window_height)
self.wm_resizable(True, True)
self.wm_geometry(f'+{left}+{top}')
def run(self):
#self.eval('tk::PlaceWindow . center')
self.mainloop()
if __name__ == '__main__':
if platform.system() == 'Windows' and int(platform.version().split('.')[0]) >= 10:
import ctypes
ctypes.windll.shcore.SetProcessDpiAwareness(1)
RealESRGANGui().run()