-
Notifications
You must be signed in to change notification settings - Fork 0
/
Win32_App.py
196 lines (160 loc) · 4.37 KB
/
Win32_App.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
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
"""
应用层,处理事件/高级算法
比起一般流程,需要多做什么工作?
1.桥接
2.事件绑定
3.字体调整
4.IDLE链接
"""
##############################
# import
##############################
# 桥接,载入GUI类
import BridgeN
st = BridgeN.Analyze(path="./GUI_Base.py")
exec(st, globals())
del st
import wx, wx.xrc
import cuwx
import win32mica
import darkdetect
import ctypes
import os
import test
##############################
# GUI的函数桥接
##############################
class CalcFrame(Main, wx.Frame):
def __init__(self, parent):
# 定义主函数
super().__init__(parent)
# 系统声明,禁用高DPI自动缩放
try:
ctypes.windll.shcore.SetProcessDpiAwareness(False)
except Exception:
pass
# 启用win11云母效果
hwnd = self.GetHandle()
mode = win32mica.MicaTheme.AUTO
style = win32mica.MicaStyle.DEFAULT
win32mica.ApplyMica(HWND=hwnd, Theme=mode, Style=style)
# 编辑器识别符
self.Butt1: cuwx.ButtonN
self.CMBA: cuwx.ComboBoxN
# 查找字体路径
directory = "./cuwx/font"
extensions = ".ttf"
re = cuwx.Font.find_files(directory, extensions)
# 安装字体(临时-关机删除)
for i in re:
path = os.path.abspath(i)
cuwx.Font.Load(path)
Englist_Font_Normal = wx.Font(
12,
wx.FONTFAMILY_MODERN,
wx.FONTSTYLE_NORMAL,
wx.FONTWEIGHT_NORMAL,
False,
"Rajdhani",
)
Englist_Font_Big = wx.Font(
17,
wx.FONTFAMILY_MODERN,
wx.FONTSTYLE_NORMAL,
wx.FONTWEIGHT_NORMAL,
False,
"Rajdhani",
)
Chinese_Font = wx.Font(
9,
wx.FONTFAMILY_MODERN,
wx.FONTSTYLE_NORMAL,
wx.FONTWEIGHT_NORMAL,
False,
"Rajdhani",
)
ICO_Font = wx.Font(
9,
wx.FONTFAMILY_MODERN,
wx.FONTSTYLE_NORMAL,
wx.FONTWEIGHT_NORMAL,
False,
"Segoe Fluent Icons",
)
self.Butt1.SetFont(Englist_Font_Normal)
self.CMBA.SetFont(ICO_Font)
# 启用双缓冲
self.SetDoubleBuffered(True)
# 刷新界面
self.Refresh_bysize()
# 绑定事件
self.Bind(cuwx.EVT_BUTTON_PUSH, self.OnLeftDown, self.Butt1)
self.Bind(cuwx.EVT_BUTTON_UP, self.OnLeftUp, self.Butt1)
self.Bind(cuwx.EVT_COMBOBOX_DOWN,self.OnComD, self.CMBA)
self.FlyWindows = cuwx.FlyoutN(self)
def MainOnSize(self, event):
event.Skip()
##print(self.GetSize())
def MainOnKeyDown(self, event):
print("检测到快捷键:" + str(event.GetKeyCode()))
key = int(event.GetKeyCode())
match key:
case 27: # ESC
self.Destroy()
case 48: # 0
pass
case 49: # 1
pass
case 50: # 2
pass
case 51: # 3
pass
case 52: # 4
pass
case 53: # 5
pass
case 54: # 6
pass
case 55: # 7
pass
case 56: # 8
pass
case 57: # 9
pass
case 340: # F1
pass
case 341: # F2
pass
case 342: # F3
pass
case 343: # F4
pass
case _:
pass
def Refresh_bysize(self):
x, y = self.GetSize()
self.SetSize(x + 1, y)
self.SetSize(x, y)
def OnLeftDown(self, event):
if self.FlyWindows.IsShown() == False:
self.FlyWindows.Show()
self.FlyWindows.Append_Text('aaa',wx.Size(100,100))
else:
self.FlyWindows.SetFocus()
def OnLeftUp(self, event):
print(2)
def OnComD(self, event):
pass
def MainOnMove(self, event):
##print(self.GetPosition())
event.Skip()
##############################
# 主函数
##############################
def main():
app = wx.App(False)
frame = CalcFrame(None)
frame.Show(True)
app.MainLoop()
if __name__ == "__main__":
main()