-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGui.py
292 lines (251 loc) · 12.3 KB
/
Gui.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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
import sys
from config import options
from TargetControl import Bot
try:
import Tkinter as tk
except ImportError:
import tkinter as tk
try:
import ttk
py3 = False
except ImportError:
import tkinter.ttk as ttk
py3 = True
import gui_support
def vp_start_gui():
'''Starting point when module is the main routine.'''
global val, w, root
root = tk.Tk()
gui_support.set_Tk_var()
top = ControlTarget (root)
gui_support.init(root, top)
root.mainloop()
w = None
def create_ControlTarget(root, *args, **kwargs):
'''Starting point when module is imported by another program.'''
global w, w_win, rt
rt = root
w = tk.Toplevel (root)
gui_support.set_Tk_var()
top = ControlTarget (w)
gui_support.init(w, top, *args, **kwargs)
return (w, top)
def destroy_ControlTarget():
global w
w.destroy()
w = None
class ControlTarget:
def __init__(self,top=None):
'''This class configures and populates the toplevel window.
top is the toplevel containing window.'''
_bgcolor = '#d9d9d9' # X11 color: 'gray85'
_fgcolor = '#000000' # X11 color: 'black'
_compcolor = '#d9d9d9' # X11 color: 'gray85'
_ana1color = '#d9d9d9' # X11 color: 'gray85'
_ana2color = '#ececec' # Closest X11 color: 'gray92'
self.style = ttk.Style()
if sys.platform == "win32":
self.style.theme_use('winnative')
self.style.configure('.',background=_bgcolor)
self.style.configure('.',foreground=_fgcolor)
self.style.configure('.',font="TkDefaultFont")
self.style.map('.',background=
[('selected', _compcolor), ('active',_ana2color)])
top.geometry("507x801+650+8")
top.title("ControlTarget")
top.configure(background="#d9d9d9")
self.lblCredentials = tk.Label(top)
self.lblCredentials.place(relx=0.0, rely=0.0, height=46, width=506)
self.lblCredentials.configure(background="#d9d9d9")
self.lblCredentials.configure(disabledforeground="#a3a3a3")
self.lblCredentials.configure(foreground="#000000")
self.lblCredentials.configure(text='''CREDENZIALI''')
self.lblCredentials.configure(width=506)
self.lblServer = tk.Label(top)
self.lblServer.place(relx=0.079, rely=0.087, height=26, width=127)
self.lblServer.configure(anchor='w')
self.lblServer.configure(background="#d9d9d9")
self.lblServer.configure(disabledforeground="#a3a3a3")
self.lblServer.configure(foreground="#000000")
self.lblServer.configure(text='''Server''')
self.lblServer.configure(width=127)
self.lblUserName = tk.Label(top)
self.lblUserName.place(relx=0.079, rely=0.137, height=26, width=75)
self.lblUserName.configure(background="#d9d9d9")
self.lblUserName.configure(disabledforeground="#a3a3a3")
self.lblUserName.configure(foreground="#000000")
self.lblUserName.configure(text='''UserName''')
self.lblPassword = tk.Label(top)
self.lblPassword.place(relx=0.079, rely=0.187, height=26, width=68)
self.lblPassword.configure(background="#d9d9d9")
self.lblPassword.configure(disabledforeground="#a3a3a3")
self.lblPassword.configure(foreground="#000000")
self.lblPassword.configure(text='''Password''')
self.lblPlayerId = tk.Label(top)
self.lblPlayerId.place(relx=0.079, rely=0.237, height=26, width=59)
self.lblPlayerId.configure(background="#d9d9d9")
self.lblPlayerId.configure(disabledforeground="#a3a3a3")
self.lblPlayerId.configure(foreground="#000000")
self.lblPlayerId.configure(text='''Player''')
self.lblSettings = tk.Label(top)
self.lblSettings.place(relx=0.0, rely=0.3, height=26, width=507)
self.lblSettings.configure(background="#d9d9d9")
self.lblSettings.configure(disabledforeground="#a3a3a3")
self.lblSettings.configure(foreground="#000000")
self.lblSettings.configure(text='''IMPOSTAZIONI''')
self.lblSettings.configure(width=507)
self.lblSeed = tk.Label(top)
self.lblSeed.place(relx=0.079, rely=0.487, height=26, width=39)
self.lblSeed.configure(background="#d9d9d9")
self.lblSeed.configure(cursor="fleur")
self.lblSeed.configure(disabledforeground="#a3a3a3")
self.lblSeed.configure(foreground="#000000")
self.lblSeed.configure(text='''Seed''')
self.lblInterval = tk.Label(top)
self.lblInterval.place(relx=0.079, rely=0.537, height=26, width=55)
self.lblInterval.configure(background="#d9d9d9")
self.lblInterval.configure(disabledforeground="#a3a3a3")
self.lblInterval.configure(foreground="#000000")
self.lblInterval.configure(text='''Interval''')
self.TSeparator1 = ttk.Separator(top)
self.TSeparator1.place(relx=-0.02, rely=0.062, relwidth=1.045)
self.TSeparator1.configure(cursor="fleur")
self.TSeparator2 = ttk.Separator(top)
self.TSeparator2.place(relx=-0.02, rely=0.287, relwidth=1.026)
self.TSeparator3 = ttk.Separator(top)
self.TSeparator3.place(relx=-0.02, rely=0.35, relwidth=1.026)
self.eSeed = tk.Entry(top)
self.eSeed.place(relx=0.335, rely=0.487, height=24, relwidth=0.619)
self.eSeed.configure(background="white")
self.eSeed.configure(disabledforeground="#a3a3a3")
self.eSeed.configure(font="TkFixedFont")
self.eSeed.configure(foreground="#000000")
self.eSeed.configure(insertbackground="black")
self.eSeed.configure(width=314)
self.eSeed.insert(0, options['general']['seed'])
self.eInterval = tk.Entry(top)
self.eInterval.place(relx=0.335, rely=0.537, height=24, relwidth=0.619)
self.eInterval.configure(background="white")
self.eInterval.configure(disabledforeground="#a3a3a3")
self.eInterval.configure(font="TkFixedFont")
self.eInterval.configure(foreground="#000000")
self.eInterval.configure(insertbackground="black")
self.eInterval.configure(width=314)
self.eInterval.insert(0, options['general']['check_interval'])
self.mSettings = tk.Message(top)
self.mSettings.place(relx=0.059, rely=0.362, relheight=0.1
, relwidth=0.88)
self.mSettings.configure(background="#d9d9d9")
self.mSettings.configure(foreground="#000000")
self.mSettings.configure(highlightbackground="#d9d9d9")
self.mSettings.configure(highlightcolor="black")
self.mSettings.configure(text='''Formula Calcolo Tempo di riposo in secondi:
t=random(seed-random(0,interval),seed+random(0,interval))
Es. seed=800,interval=50
t=numero compreso tra 750 e 850''')
self.mSettings.configure(width=446)
self.TSeparator4 = ttk.Separator(top)
self.TSeparator4.place(relx=0.0, rely=0.587, relwidth=1.006)
self.lblTarget = tk.Label(top)
self.lblTarget.place(relx=0.0, rely=0.599, height=26, width=509)
self.lblTarget.configure(background="#d9d9d9")
self.lblTarget.configure(disabledforeground="#a3a3a3")
self.lblTarget.configure(foreground="#000000")
self.lblTarget.configure(text='''TARGET''')
self.lblTarget.configure(width=509)
self.TSeparator5 = ttk.Separator(top)
self.TSeparator5.place(relx=-0.02, rely=0.637, relwidth=1.026)
self.mTarget = tk.Message(top)
self.mTarget.place(relx=0.039, rely=0.662, relheight=0.037
, relwidth=0.939)
self.mTarget.configure(background="#d9d9d9")
self.mTarget.configure(foreground="#000000")
self.mTarget.configure(highlightbackground="#d9d9d9")
self.mTarget.configure(highlightcolor="black")
self.mTarget.configure(text='''Inserire i nomi dei target separati da && (2&)''')
self.mTarget.configure(width=476)
self.eServer = tk.Entry(top)
self.eServer.place(relx=0.335, rely=0.087,height=24, relwidth=0.619)
self.eServer.configure(background="white")
self.eServer.configure(disabledforeground="#a3a3a3")
self.eServer.configure(font="TkFixedFont")
self.eServer.configure(foreground="#000000")
self.eServer.configure(insertbackground="black")
self.eServer.configure(width=314)
self.eServer.insert(0, options['credentials']['server'])
self.eUserName = tk.Entry(top,textvariable=options['credentials']['username'])
self.eUserName.place(relx=0.335, rely=0.137,height=24, relwidth=0.619)
self.eUserName.configure(background="white")
self.eUserName.configure(disabledforeground="#a3a3a3")
self.eUserName.configure(font="TkFixedFont")
self.eUserName.configure(foreground="#000000")
self.eUserName.configure(insertbackground="black")
self.eUserName.configure(width=314)
self.eUserName.insert(0,options['credentials']['username'])
self.ePassword = tk.Entry(top)
self.ePassword.place(relx=0.335, rely=0.187,height=24, relwidth=0.619)
self.ePassword.configure(background="white")
self.ePassword.configure(disabledforeground="#a3a3a3")
self.ePassword.configure(font="TkFixedFont")
self.ePassword.configure(foreground="#000000")
self.ePassword.configure(insertbackground="black")
self.ePassword.configure(width=314)
self.ePassword.insert(0,options['credentials']['password'])
self.ePlayerId = tk.Entry(top)
self.ePlayerId.place(relx=0.335, rely=0.237,height=24, relwidth=0.619)
self.ePlayerId.configure(background="white")
self.ePlayerId.configure(disabledforeground="#a3a3a3")
self.ePlayerId.configure(font="TkFixedFont")
self.ePlayerId.configure(foreground="#000000")
self.ePlayerId.configure(insertbackground="black")
self.ePlayerId.configure(width=314)
self.ePlayerId.insert(0, options['credentials']['player'])
self.eTargets = tk.Entry(top)
self.eTargets.place(relx=0.039, rely=0.82,height=34, relwidth=0.915)
self.eTargets.configure(background="white")
self.eTargets.configure(disabledforeground="#a3a3a3")
self.eTargets.configure(font="TkFixedFont")
self.eTargets.configure(foreground="#000000")
self.eTargets.configure(insertbackground="black")
self.eTargets.configure(width=464)
self.eTargets.insert(0,options['targets']['name'])
self.btStart = tk.Button(top)
self.btStart.place(relx=0.039, rely=0.894, height=53, width=226)
self.btStart.configure(activebackground="#ececec")
self.btStart.configure(activeforeground="#000000")
self.btStart.configure(background="#d9d9d9")
self.btStart.configure(command=self.startBot)
self.btStart.configure(disabledforeground="#a3a3a3")
self.btStart.configure(foreground="#000000")
self.btStart.configure(highlightbackground="#d9d9d9")
self.btStart.configure(highlightcolor="black")
self.btStart.configure(pady="0")
self.btStart.configure(text='''Start''')
self.btStart.configure(width=226)
self.btSave = tk.Button(top)
self.btSave.place(relx=0.513, rely=0.894, height=53, width=226)
self.btSave.configure(activebackground="#ececec")
self.btSave.configure(activeforeground="#000000")
self.btSave.configure(background="#d9d9d9")
self.btSave.configure(command=self.saveConfig)
self.btSave.configure(disabledforeground="#a3a3a3")
self.btSave.configure(foreground="#000000")
self.btSave.configure(highlightbackground="#d9d9d9")
self.btSave.configure(highlightcolor="black")
self.btSave.configure(pady="0")
self.btSave.configure(text='''Salva''')
self.btSave.configure(width=226)
def saveConfig(self):
options.updateValue('credentials', 'server', self.eServer.get())
options.updateValue('credentials', 'username', self.eUserName.get())
options.updateValue('credentials', 'password', self.ePassword.get())
options.updateValue('credentials', 'player', self.ePlayerId.get())
options.updateValue('general', 'seed', self.eSeed.get())
options.updateValue('general', 'check_interval', self.eInterval.get())
options.updateValue('targets', 'name', self.eTargets.get())
def startBot(self):
self.saveConfig()
bot = Bot()
bot.start()
if __name__ == '__main__':
vp_start_gui()