-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathui.py
49 lines (39 loc) · 1.29 KB
/
ui.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
47
48
49
from big_boss import *
from PyQt5.QtGui import QTextCursor
from PyQt5.QtWidgets import QApplication, QMainWindow
from Ui_big_boss import *
import logging
class GuiLogger(logging.Handler):
def emit(self, record):
self.edit.append(self.format(record)) # implementation of append_line omitted
self.edit.moveCursor(QTextCursor.End)
class MyMainWindow(QMainWindow):
def __init__(self, parent = None):
super(MyMainWindow, self).__init__(parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.ui.textEdit.ensureCursorVisible()
# 将日志转存至UI
h = GuiLogger()
h.edit = self.ui.textEdit
logger = logging.getLogger()
logger.setLevel(logging.INFO)
logger.addHandler(h)
def start_onmyoji(self):
start()
def stop_onmyoji(self):
logging.info('Quitting!')
os._exit(0)
if __name__=="__main__":
try:
# 检测管理员权限
if is_admin():
log.writeinfo('UAC pass')
app = QApplication(sys.argv)
myWin = MyMainWindow()
myWin.show()
sys.exit(app.exec_())
else:
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, __file__, None, 1)
except:
pass