Skip to content

Commit

Permalink
refactor: move dpi method
Browse files Browse the repository at this point in the history
  • Loading branch information
latorc committed Apr 18, 2024
1 parent baf41a5 commit ff604bc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
12 changes: 11 additions & 1 deletion common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from enum import Enum
import pathlib
import sys
import ctypes
import time
import subprocess
import random
Expand Down Expand Up @@ -133,13 +134,22 @@ def list_files(folder:str, full_path:bool=False) -> list[pathlib.Path]:
return [str(f.resolve()) for f in files]
else:
return [f.name for f in files]
except:
except: #pylint:disable=bare-except
return []

def random_str(length:int) -> str:
""" Generate random string with specified length"""
return ''.join(random.choices(string.ascii_letters + string.digits, k=length))

def set_dpi_awareness():
""" Set DPI Awareness """
if sys.platform == "win32":
try:
ctypes.windll.shcore.SetProcessDpiAwareness(1) # for Windows 8.1 and later
except AttributeError:
ctypes.windll.user32.SetProcessDPIAware() # for Windows Vista and later
except: #pylint:disable=bare-except
pass
class FPSCounter:
""" for counting frames and calculate fps"""
def __init__(self):
Expand Down
13 changes: 1 addition & 12 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
""" Main Entry Point for Mahjong Copilot """
import ctypes
import sys
from gui.main_gui import MainGUI
from common.log_helper import LogHelper
from common.settings import Settings
from bot_manager import BotManager

def set_dpi_awareness():
""" Set DPI Awareness """
if sys.platform == "win32":
try:
ctypes.windll.shcore.SetProcessDpiAwareness(1) # for Windows 8.1 and later
except AttributeError:
ctypes.windll.user32.SetProcessDPIAware() # for Windows Vista and later
except: #pylint:disable=bare-except
pass

def main():
""" Main entry point """
LogHelper.config_logging()
setting = Settings()
# set_dpi_awareness()
# utils.set_dpi_awareness()
bot_manager = BotManager(setting)
gui = MainGUI(setting, bot_manager)
gui.mainloop()
Expand Down

0 comments on commit ff604bc

Please sign in to comment.