1
+ from tool import *
1
2
from tkinter import *
2
3
from tkinter .ttk import *
3
- import os
4
- import json
5
4
6
5
7
- def Read_MAA_Config (path ):
8
-
9
- with open (path ,"r" ,encoding = 'utf-8' ) as MAA_Config :
10
- #打开json并传入MAA_data
11
- MAA_data = json .load (MAA_Config )
12
- return MAA_data
13
-
14
- def Save_MAA_Config (path ,date ):
15
- #打开json并写入data内数据
16
- with open (path ,"w" ,encoding = 'utf-8' ) as MAA_Config :
17
- json .dump (date ,MAA_Config ,indent = 4 ,ensure_ascii = False )
18
-
19
- def Get_Values_list (path ,key1 ):
20
- #获取组件的初始参数
21
- List = []
22
- for i in Read_MAA_Config (path )[key1 ]:
23
- List .append (i ["name" ])
24
- return List
25
-
26
- def Get_Values_list_Option (path ,key1 ):
27
- #获取组件的初始参数
28
- List = []
29
- for i in Read_MAA_Config (path )[key1 ]:
30
- if i ["option" ]!= []:
31
- Option_text = str (i ["name" ])+ " "
32
- Option_Lens = len (i ["option" ])
33
- for t in range (0 ,Option_Lens ,1 ):
34
- Option_text += str (i ["option" ][t ]["value" ])+ " "
35
- List .append (Option_text )
36
- else :
37
- List .append (i ["name" ])
38
- return List
39
-
40
6
class WinGUI (Tk ):
41
7
def __init__ (self ):
42
8
super ().__init__ ()
@@ -65,6 +31,13 @@ def __init__(self):
65
31
self .tk_label_Add_Task_Label_4 = self .__tk_label_Add_Task_Label_4 (self )
66
32
self .tk_label_Add_Task_Label_5 = self .__tk_label_Add_Task_Label_5 (self )
67
33
self .tk_label_Add_Task_Label_6 = self .__tk_label_Add_Task_Label_6 (self )
34
+ self .tk_label_Controller_Type_Label = self .__tk_label_Controller_Type_Label (self )
35
+ self .tk_select_box_Controller_Type_Select = self .__tk_select_box_Controller_Type_Select (self )
36
+ self .tk_input_Input_Author_Name = self .__tk_input_Input_Author_Name (self )
37
+ self .tk_button_Update_button = self .__tk_button_Update_button (self )
38
+ self .tk_label_Author_Name_Label = self .__tk_label_Author_Name_Label (self )
39
+ self .tk_label_Project_Name_Label = self .__tk_label_Project_Name_Label (self )
40
+ self .tk_input_Project_Name = self .__tk_input_Project_Name (self )
68
41
def __win (self ):
69
42
self .title ("MAA-GUI" )
70
43
# 设置窗口大小、居中
@@ -166,6 +139,11 @@ def __tk_list_box_Task_List(self,parent):
166
139
lb .insert (END , item )
167
140
lb .place (x = 360 , y = 40 , width = 220 , height = 400 )
168
141
return lb
142
+ def __tk_select_box_Controller_Type_Select (self ,parent ):
143
+ cb = Combobox (parent , state = "readonly" , )
144
+ cb ['values' ] = (Get_Values_list (os .getcwd ()+ "\MAA_bin\interface.json" ,"controller" ))
145
+ cb .place (x = 260 , y = 80 , width = 80 , height = 30 )
146
+ return cb
169
147
def __tk_button_Move_Up_Button (self ,parent ):
170
148
btn = Button (parent , text = "上移" , takefocus = False ,)
171
149
btn .place (x = 360 , y = 460 , width = 50 , height = 30 )
@@ -214,6 +192,30 @@ def __tk_label_Add_Task_Label_6(self,parent):
214
192
label = Label (parent ,text = "4号标签" ,anchor = "center" , )
215
193
label .place (x = 0 , y = 320 , width = 70 , height = 30 )
216
194
return label
195
+ def __tk_label_Controller_Type_Label (self ,parent ):
196
+ label = Label (parent ,text = "控制端" ,anchor = "center" , )
197
+ label .place (x = 180 , y = 80 , width = 70 , height = 30 )
198
+ return label
199
+ def __tk_input_Input_Author_Name (self ,parent ):
200
+ ipt = Entry (parent , )
201
+ ipt .place (x = 80 , y = 360 , width = 80 , height = 30 )
202
+ return ipt
203
+ def __tk_button_Update_button (self ,parent ):
204
+ btn = Button (parent , text = "更新" , takefocus = False ,)
205
+ btn .place (x = 290 , y = 400 , width = 50 , height = 30 )
206
+ return btn
207
+ def __tk_label_Author_Name_Label (self ,parent ):
208
+ label = Label (parent ,text = "作者名" ,anchor = "center" , )
209
+ label .place (x = 0 , y = 360 , width = 70 , height = 30 )
210
+ return label
211
+ def __tk_label_Project_Name_Label (self ,parent ):
212
+ label = Label (parent ,text = "项目名" ,anchor = "center" , )
213
+ label .place (x = 180 , y = 360 , width = 70 , height = 30 )
214
+ return label
215
+ def __tk_input_Project_Name (self ,parent ):
216
+ ipt = Entry (parent , )
217
+ ipt .place (x = 260 , y = 360 , width = 80 , height = 30 )
218
+ return ipt
217
219
class Win (WinGUI ):
218
220
def __init__ (self , controller ):
219
221
self .ctl = controller
@@ -227,11 +229,15 @@ def __event_bind(self):
227
229
self .tk_input_ADB_Path_Input .bind ('<Return>' ,self .ctl .Save_ADB_Path )
228
230
self .tk_input_ADB_Address_Input .bind ('<Return>' ,self .ctl .Save_ADB_Address )
229
231
self .tk_select_box_Resource_Type_Select .bind ('<<ComboboxSelected>>' ,self .ctl .Save_Resource_Type_Select )
232
+ self .tk_select_box_Resource_Type_Select .bind ('<Button-1>' ,self .ctl .Save_ADB_Path )
230
233
self .tk_select_box_Add_Task_Select .bind ('<<ComboboxSelected>>' ,self .ctl .Add_Task_Select_More_Select )
234
+ self .tk_select_box_Add_Task_Select .bind ('<Enter>' ,self .ctl .Save_ADB_Address )
231
235
self .tk_button_Add_Task_Button .bind ('<Button-1>' ,self .ctl .Add_Task )
232
236
self .tk_button_Move_Up_Button .bind ('<Button-1>' ,self .ctl .Click_Move_Up_Button )
233
237
self .tk_button_Move_Down_Button .bind ('<Button-1>' ,self .ctl .Click_Move_Down_Button )
234
238
self .tk_button_Delete_Button .bind ('<Button-1>' ,self .ctl .Click_Delete_Button )
239
+ self .tk_select_box_Controller_Type_Select .bind ('<<ComboboxSelected>>' ,self .ctl .Save_Controller_Type_Select )
240
+ self .tk_list_box_Task_List .bind ('<Delete>' ,self .ctl .Click_Delete_Button )
235
241
pass
236
242
def __style_config (self ):
237
243
pass
0 commit comments