-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtempus.py
381 lines (313 loc) · 19.2 KB
/
tempus.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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
from tkinter import *
from tkinter import ttk
import subprocess
import shellconnect
import array
#adobe colors
colorDown = '#31deb5'
colorMain = '#42f498'
colorUp = '#31de53'
colorMenuShade = '#2c2d32'
colorShadeLighter = '#5f626e'
colorShadeNormal = '#383940'
colorShadeDarker = '#222226'
currentlyConnectedEmulators = []
currentlyConnectedPorts = []
class Window(object):
def __init__(self, master):
self.scriptsRadioButtonChoice = IntVar(app)
self.scriptsComboboxChoice = StringVar(app)
self.master = master
self.master.title("tempus")
self.master.geometry("630x405+300+200")
self.master.configure(bg=colorShadeNormal)
self.master.resizable(0,0)
self.AddWidgets()
self.btnRefreshEmulatorsPushed()
def AddWidgets(self):
#menu bar, home, skills, cash, settings, help
self.MenuBar = Frame(self.master, bg=colorMenuShade, width=630, height=40)
self.MenuBar.pack(fill=X)
self.btnOverview = Button(self.MenuBar, text='Overview', font='Roboto', bd=0, bg=colorMain, activebackground=colorMenuShade, activeforeground='#fff', highlightcolor=colorShadeLighter, fg='#fff', command=self.overviewPushed, state=DISABLED)
self.btnOverview.pack(side=LEFT,fill=BOTH,expand=Y)
self.btnScripts = Button(self.MenuBar, text='Scripts', font='Roboto', bd=0, bg=colorMenuShade, activebackground=colorMenuShade, activeforeground='#fff', highlightcolor=colorShadeLighter, fg='#fff', command=self.scriptsPushed)
self.btnScripts.pack(side=LEFT,fill=BOTH,expand=Y)
self.btnSettings = Button(self.MenuBar, text='Settings', font='Roboto', bd=0, bg=colorMenuShade, activebackground=colorMenuShade, activeforeground='#fff', fg='#fff', command=self.settingsPushed)
self.btnSettings.pack(side=LEFT,fill=BOTH,expand=Y)
self.btnHelp = Button(self.MenuBar, text='Help', font='Roboto', bd=0, bg=colorMenuShade, activebackground=colorMenuShade, activeforeground='#fff', fg='#fff', command=self.helpPushed)
self.btnHelp.pack(side=LEFT,fill=BOTH,expand=Y)
self.createOverviewTab()
def overviewPushed(self):
if (self.btnOverview['state'] == NORMAL):
if (self.btnScripts['state'] == DISABLED):
self.ScriptsBodyFrame.destroy()
if (self.btnSettings['state'] == DISABLED):
self.SettingsBodyFrame.destroy()
if (self.btnHelp['state'] == DISABLED):
self.HelpBodyFrame.destroy()
self.BodyBottomFrame.destroy()
self.createOverviewTab()
self.lblTitle['text'] = 'This is where you can monitor your bots live with Tasks, Scripts, and whether they are Connected.'
self.btnScripts['bg'] = colorMenuShade
self.btnScripts['state'] = NORMAL
self.btnSettings['bg'] = colorMenuShade
self.btnSettings['state'] = NORMAL
self.btnHelp['bg'] = colorMenuShade
self.btnHelp['state'] = NORMAL
self.btnOverview['state'] = DISABLED
self.btnOverview['bg'] = colorMain
else:
self.btnOverview['state'] = NORMAL
self.btnOverview['bg'] = colorMenuShade
def scriptsPushed(self):
if (self.btnScripts['state'] == NORMAL):
if (self.btnOverview['state'] == DISABLED):
self.OverviewBodyFrame.destroy()
if (self.btnSettings['state'] == DISABLED):
self.SettingsBodyFrame.destroy()
if (self.btnHelp['state'] == DISABLED):
self.HelpBodyFrame.destroy()
self.BodyBottomFrame.destroy()
self.createScriptsTab()
self.lblTitle['text'] = 'This contains all Skilling and Money Making scripts.'
self.btnOverview['bg'] = colorMenuShade
self.btnOverview['state'] = NORMAL
self.btnSettings['bg'] = colorMenuShade
self.btnSettings['state'] = NORMAL
self.btnHelp['bg'] = colorMenuShade
self.btnHelp['state'] = NORMAL
self.btnScripts['state'] = DISABLED
self.btnScripts['bg'] = colorMain
else:
self.btnScripts['state'] = NORMAL
self.btnScripts['bg'] = colorMenuShade
def settingsPushed(self):
if (self.btnSettings['state'] == NORMAL):
if (self.btnScripts['state'] == DISABLED):
self.ScriptsBodyFrame.destroy()
if (self.btnOverview['state'] == DISABLED):
self.OverviewBodyFrame.destroy()
if (self.btnHelp['state'] == DISABLED):
self.HelpBodyFrame.destroy()
self.BodyBottomFrame.destroy()
self.createSettingsTab()
self.lblTitle['text'] = 'Fine tunings of the tempus.'
self.btnSettings['state'] = DISABLED
self.btnSettings['bg'] = colorMain
self.btnOverview['bg'] = colorMenuShade
self.btnOverview['state'] = NORMAL
self.btnScripts['bg'] = colorMenuShade
self.btnScripts['state'] = NORMAL
self.btnHelp['bg'] = colorMenuShade
self.btnHelp['state'] = NORMAL
else:
self.btnSettings['state'] = NORMAL
self.btnSettings['bg'] = colorMenuShade
def helpPushed(self):
if (self.btnHelp['state'] == NORMAL):
if (self.btnScripts['state'] == DISABLED):
self.ScriptsBodyFrame.destroy()
if (self.btnSettings['state'] == DISABLED):
self.SettingsBodyFrame.destroy()
if (self.btnOverview['state'] == DISABLED):
self.OverviewBodyFrame.destroy()
self.BodyBottomFrame.destroy()
self.createHelpTab()
self.lblTitle['text'] = 'Help reguarding Setting up and Tips to keep your bots alive longer.'
self.btnHelp['state'] = DISABLED
self.btnHelp['bg'] = colorMain
self.btnOverview['bg'] = colorMenuShade
self.btnOverview['state'] = NORMAL
self.btnSettings['bg'] = colorMenuShade
self.btnSettings['state'] = NORMAL
self.btnScripts['bg'] = colorMenuShade
self.btnScripts['state'] = NORMAL
else:
self.btnHelp['state'] = NORMAL
self.btnHelp['bg'] = colorMenuShade
def btnRefreshEmulatorsPushed(self):
self.btnRefreshEmulators['bg'] = colorMain
self.btnRefreshEmulators['state'] = DISABLED
self.lblAmountConnected['text'] = 'Device(s) Connected: Refreshing'
global currentlyConnectedEmulators
global currentlyConnectedPorts
currentlyConnectedPorts = shellconnect.connectToBluestacks()
currentlyConnectedEmulators = []
if len(currentlyConnectedPorts) > 0:
for x in range(0, len(currentlyConnectedPorts)):
currentlyConnectedEmulators.append(['BlueStacks:' + str(currentlyConnectedPorts[x])])
else:
currentlyConnectedEmulators = ['nothing connected', '', '', '']
self.lblAmountConnected['text'] = 'Device(s) Connected: ' + str(len(currentlyConnectedPorts))
self.overviewRecreateConnectedLabels()
self.btnRefreshEmulators['state'] = ACTIVE
self.btnRefreshEmulators['bg'] = colorMenuShade
def createOverviewTab(self):
#TOP FULL BODY FRAME
self.OverviewBodyFrame = Frame(self.master, bg=colorShadeNormal, width=630, bd=2)
self.OverviewBodyFrame.pack(fill=BOTH, expand=Y)
#TOP BODY SHOWING CONNECTED
self.OverviewTopBodyFrame = Frame(self.OverviewBodyFrame, bg=colorShadeNormal, width=630, height=30, bd=0)
self.OverviewTopBodyFrame.pack(fill=X, anchor=N)
if len(currentlyConnectedPorts) > 0:
ammountConnectedString = "Device(s) Connected: " + str(len(currentlyConnectedPorts))
else:
ammountConnectedString = "Device(s) Connected: " + str(len(currentlyConnectedPorts)) + ", Please Refresh"
self.lblAmountConnected = Label(self.OverviewTopBodyFrame, text=ammountConnectedString, font='Roboto, 10', padx=5, pady=5, bd=0, bg=colorShadeNormal, fg='#fff')
self.lblAmountConnected.place(relx=0, x=0, y=0, anchor=NW)
self.btnRefreshEmulators = Button(self.OverviewTopBodyFrame, text='Refresh', font='Roboto, 10', padx=5, pady=2, bd=0, bg=colorMenuShade, activebackground=colorMenuShade, highlightcolor=colorShadeLighter, activeforeground='#fff', fg='#fff', command=self.btnRefreshEmulatorsPushed)
self.btnRefreshEmulators.place(relx=1, x=0,y=0, anchor=NE)
#OVERVIEW CENTER BODY
self.OverviewBodyCenterFrame = Frame(self.OverviewBodyFrame, bg=colorShadeNormal, bd=0)
self.OverviewBodyCenterFrame.pack(fill=BOTH, expand=Y)
self.overviewCreateTitleLabels()
self.overviewRecreateConnectedLabels()
self.OverviewBodyCenterFrame.columnconfigure(0, weight=3)
self.OverviewBodyCenterFrame.columnconfigure(1, weight=3)
self.OverviewBodyCenterFrame.columnconfigure(2, weight=3)
self.OverviewBodyCenterFrame.columnconfigure(3, weight=0)
#BOTTOM BODY
self.BodyBottomFrame = Frame(self.master, bg=colorShadeNormal, width=630, height=30, bd=0)
self.BodyBottomFrame.pack(fill=X, anchor=S)
self.lblTitle = Label(self.BodyBottomFrame, text='This is where you can monitor your bots live with current Tasks, Thoughts, and whether they are Connected.', font='Roboto, 10', padx=5, pady=5, bd=0, bg=colorShadeNormal, fg='#fff')
self.lblTitle.place(relx=0, rely=1, x=0, y=0, anchor=SW)
def createScriptsTab(self):
#TOP FULL BODY FRAME
self.ScriptsBodyFrame = Frame(self.master, bg=colorShadeNormal, width=630, bd=2)
self.ScriptsBodyFrame.pack(fill=BOTH, expand=Y)
#TOP BODY SHOWING CONNECTED
self.ScriptsTopBodyFrame = Frame(self.ScriptsBodyFrame, bg=colorShadeNormal, width=630, height=30, bd=0)
self.ScriptsTopBodyFrame.pack(fill=X, anchor=N)
if len(currentlyConnectedPorts) > 0:
ammountConnectedString = "Device(s) Connected: " + str(len(currentlyConnectedPorts))
else:
ammountConnectedString = "Device(s) Connected: " + str(len(currentlyConnectedPorts)) + ", Please Refresh"
self.lblAmountConnected = Label(self.ScriptsTopBodyFrame, text=ammountConnectedString, font='Roboto, 10', padx=5, pady=5, bd=0, bg=colorShadeNormal, fg='#fff')
self.lblAmountConnected.place(relx=0, x=0, y=0, anchor=NW)
currentlyConnectedCombobox = ttk.Combobox(self.ScriptsTopBodyFrame, width = 35, textvariable = self.scriptsComboboxChoice, takefocus=False, state="readonly")
if len(currentlyConnectedPorts) > 0:
temp = []
for emulator in range(0,len(currentlyConnectedPorts)):
temp.append(str(currentlyConnectedEmulators[emulator][0]))
# Adding combobox drop down list
currentlyConnectedCombobox['values'] = temp
currentlyConnectedCombobox['state'] = "readonly"
else:
currentlyConnectedCombobox['values'] = ['Please Connect and/or Refresh devices']
currentlyConnectedCombobox['state'] = DISABLED
currentlyConnectedCombobox.bind("<<ComboboxSelected>>",lambda e: self.ScriptsBodyFrame.focus())
currentlyConnectedCombobox.place(relx=1, x=-48, y=2, anchor=NE)
currentlyConnectedCombobox.current(0)
#Scripts CENTER BODY
self.ScriptsBodyCenterFrame = Frame(self.ScriptsBodyFrame, bg=colorShadeNormal, bd=0)
self.ScriptsBodyCenterFrame.pack(fill=BOTH, expand=Y)
btnStartScripts = Button(self.ScriptsBodyCenterFrame, text='Start', font='Roboto, 10', padx=5, pady=5, bd=0, bg=colorShadeLighter, activebackground=colorMenuShade, activeforeground=colorShadeLighter, fg='#fff', command=self.callBackStartScripts)
btnStartScripts.grid(sticky=W+E+S, row=0, column=0, columnspan=3, padx=5, pady=5)
self.lblTitleName = Label(self.ScriptsBodyCenterFrame, text='Categories', font='Roboto, 10', padx=5, pady=5, bd=0, bg=colorShadeNormal, fg=colorShadeLighter).grid(sticky=W, row=1, column=0)
SCRIPT_CATEGORIES = [
("Combat"),
("Prayer"),
("Magic"),
("Runecrafting"),
("Construction"),
("Agility"),
("Mining"),
("Woodcutting"),
("Smithing"),
]
row = 2
column = 0
for x in range(0, len(SCRIPT_CATEGORIES)):
b = Radiobutton(self.ScriptsBodyCenterFrame, text=SCRIPT_CATEGORIES[x], width=30, anchor=W, variable=self.scriptsRadioButtonChoice,
activebackground=colorMenuShade, activeforeground=colorShadeLighter, selectcolor=colorMain, fg='#fff', bg=colorShadeLighter, indicatoron=0,
padx=2, pady=2, value=x, bd=0, relief=RIDGE, command=self.scriptsRecolorAllRadioButtons)
b.grid(sticky=W, row=row, column=column, padx=5, pady=5)
column += 1
if column > 2:
row += 1
column = 0
self.ScriptsBodyCenterFrame.columnconfigure(0, weight=3)
self.ScriptsBodyCenterFrame.columnconfigure(1, weight=3)
self.ScriptsBodyCenterFrame.columnconfigure(2, weight=3)
Button(self.ScriptsBodyCenterFrame, text = "check rads", width=30, bg=colorShadeLighter, activebackground=colorMenuShade, activeforeground=colorShadeLighter, bd=0, compound=LEFT, command=self.scriptsRecolorAllRadioButtons).grid(sticky=E, row=5, column=0, padx=5, pady=5)
#BOTTOM BODY
self.BodyBottomFrame = Frame(self.master, bg=colorShadeNormal, width=630, height=30, bd=0)
self.BodyBottomFrame.pack(fill=X, anchor=S)
self.lblTitle = Label(self.BodyBottomFrame, text='', font='Roboto, 10', padx=5, pady=5, bd=0, bg=colorShadeNormal, fg='#fff')
self.lblTitle.place(relx=0, rely=1, x=0, y=0, anchor=SW)
def createSettingsTab(self):
#TOP FULL BODY FRAME
self.SettingsBodyFrame = Frame(self.master, bg=colorShadeNormal, width=630, bd=2)
self.SettingsBodyFrame.pack(fill=BOTH, expand=Y)
#TOP BODY SHOWING CONNECTED
self.SettingsTopBodyFrame = Frame(self.SettingsBodyFrame, bg=colorShadeNormal, width=630, height=30, bd=0)
self.SettingsTopBodyFrame.pack(fill=X, anchor=N)
#Settings CENTER BODY
self.SettingsBodyCenterFrame = Frame(self.SettingsBodyFrame, bg=colorShadeNormal, bd=0)
self.SettingsBodyCenterFrame.pack(fill=BOTH, expand=Y)
#BOTTOM BODY
self.BodyBottomFrame = Frame(self.master, bg=colorShadeNormal, width=630, height=30, bd=0)
self.BodyBottomFrame.pack(fill=X, anchor=S)
self.lblTitle = Label(self.BodyBottomFrame, text='', font='Roboto, 10', padx=5, pady=5, bd=0, bg=colorShadeNormal, fg='#fff')
self.lblTitle.place(relx=0, rely=1, x=0, y=0, anchor=SW)
def createHelpTab(self):
#TOP FULL BODY FRAME
self.HelpBodyFrame = Frame(self.master, bg=colorShadeNormal, width=630, bd=2)
self.HelpBodyFrame.pack(fill=BOTH, expand=Y)
#TOP BODY SHOWING CONNECTED
self.HelpTopBodyFrame = Frame(self.HelpBodyFrame, bg=colorShadeNormal, width=630, height=30, bd=0)
self.HelpTopBodyFrame.pack(fill=X, anchor=N)
#Help CENTER BODY
self.HelpBodyCenterFrame = Frame(self.HelpBodyFrame, bg=colorShadeNormal, bd=0)
self.HelpBodyCenterFrame.pack(fill=BOTH, expand=Y)
#BOTTOM BODY
self.BodyBottomFrame = Frame(self.master, bg=colorShadeNormal, width=630, height=30, bd=0)
self.BodyBottomFrame.pack(fill=X, anchor=S)
self.lblTitle = Label(self.BodyBottomFrame, text='', font='Roboto, 10', padx=5, pady=5, bd=0, bg=colorShadeNormal, fg='#fff')
self.lblTitle.place(relx=0, rely=1, x=0, y=0, anchor=SW)
def overviewRecreateConnectedLabels(self):
self.overviewDestroyAllLabels()
global currentlyConnectedEmulators
global currentlyConnectedPorts
if len(currentlyConnectedPorts) > 0:
currentlyConnectedEmulators = [[]]
for x in range(0, len(currentlyConnectedPorts)):
currentlyConnectedEmulators.insert(x, ['BlueStacks:' + str(currentlyConnectedPorts[x]),'nothing','nothing','0:00:00'])
self.overviewCreateConnectedLabels(currentlyConnectedEmulators[x][0],currentlyConnectedEmulators[x][1],currentlyConnectedEmulators[x][2],currentlyConnectedEmulators[x][3],x+1)
else:
self.lblAmountConnected['text'] = 'Device(s) Connected: 0, Are you sure BlueStacks is running?'
self.overviewCreateConnectedLabels('not connected', '', '', '', 1)
def overviewCreateConnectedLabels(self, name, action, thoughts, runtime, currentRow):
Label(self.OverviewBodyCenterFrame, text=name, font='Roboto, 10', padx=5, pady=5, bd=0, bg=colorShadeNormal, fg='#fff').grid(sticky=W, row=currentRow, column=0)
Label(self.OverviewBodyCenterFrame, text=action, font='Roboto, 10', padx=5, pady=5, bd=0, bg=colorShadeNormal, fg='#fff').grid(sticky=W, row=currentRow, column=1)
Label(self.OverviewBodyCenterFrame, text=thoughts, font='Roboto, 10', padx=5, pady=5, bd=0, bg=colorShadeNormal, fg='#fff').grid(sticky=W, row=currentRow, column=2)
Label(self.OverviewBodyCenterFrame, text=runtime, font='Roboto, 10', padx=5, pady=5, bd=0, bg=colorShadeNormal, fg='#fff').grid(sticky=E, row=currentRow, column=3)
def overviewCreateTitleLabels(self):
self.lblTitleName = Label(self.OverviewBodyCenterFrame, text='Name', font='Roboto, 10', padx=5, pady=5, bd=0, bg=colorShadeNormal, fg=colorShadeLighter).grid(sticky=W, row=0, column=0)
self.lblCurrentAction = Label(self.OverviewBodyCenterFrame, text='Current Action', font='Roboto, 10', padx=5, pady=5, bd=0, bg=colorShadeNormal, fg=colorShadeLighter).grid(sticky=W, row=0, column=1)
self.lblTitleThoughts = Label(self.OverviewBodyCenterFrame, text='Thoughts', font='Roboto, 10', padx=5, pady=5, bd=0, bg=colorShadeNormal, fg=colorShadeLighter).grid(sticky=W, row=0, column=2)
self.lblTitleRuntime = Label(self.OverviewBodyCenterFrame, text='Runtime', font='Roboto, 10', padx=5, pady=5, bd=0, bg=colorShadeNormal, fg=colorShadeLighter).grid(sticky=W, row=0, column=3)
def overviewDestroyAllLabels(self):
list = self.OverviewBodyCenterFrame.grid_slaves()
for l in list:
l.destroy()
self.overviewCreateTitleLabels()
def scriptsRecolorAllRadioButtons(self):
list = self.ScriptsBodyCenterFrame.grid_slaves()
for l in list:
if l['state'] == 'ACTIVE':
l['bg'] == colorMain
l['fg'] == colorShadeNormal
else:
l['bg'] == colorShadeNormal
l['fg'] == '#fff'
def callBackStartScripts(self):
stdoutlineformatted = ''
item = subprocess.Popen([sys.executable, 'shellinterpreter.py', self.scriptsComboboxChoice.get()[self.scriptsComboboxChoice.get().find(':')+1:len(self.scriptsComboboxChoice.get())]], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for stdoutline in item.stdout:
stdoutlineformatted += str(stdoutline, 'utf-8')
#shellinterpreter.mineIronOreSouthEastVarrock(self.scriptsComboboxChoice.get()[self.scriptsComboboxChoice.get().find(':')+1:len(self.scriptsComboboxChoice.get())],self.scriptsRadioButtonChoice.get())
app = Tk()
app.iconbitmap('src/tempus.ico')
Window = Window(app)
app.mainloop()