AutoPercenty3/main.py

40 lines
1.0 KiB
Python

import ctypes
from PySide6.QtWidgets import QApplication
from gui import AutoPercentyGUI
from logger_module import setup_logger
import sys
import os
# 절전모드를 방지하는 설정 값
ES_CONTINUOUS = 0x80000000
ES_SYSTEM_REQUIRED = 0x00000001
def prevent_sleep():
"""절전모드 방지를 위해 시스템 설정을 변경"""
ctypes.windll.kernel32.SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED)
def allow_sleep():
"""절전모드 방지 설정을 해제"""
ctypes.windll.kernel32.SetThreadExecutionState(ES_CONTINUOUS)
if __name__ == '__main__':
app = QApplication([])
# 로깅 설정
logger = setup_logger('default_logger', 'AutoPercenty3.log')
# 절전모드 방지 활성화
prevent_sleep()
# PySide6 GUI 실행
window = AutoPercentyGUI(logger)
window.show()
# 프로그램 종료 처리
try:
app.exec()
finally:
# 프로그램 종료 시 close 메서드 호출
window.close()
allow_sleep() # 종료 후 절전모드 허용