-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui1.py
346 lines (301 loc) · 13.5 KB
/
gui1.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
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
# GUI module generated by PAGE version 4.18
# in conjunction with Tcl version 8.6
# Nov 11, 2018 03:57:00 PM CET platform: Windows NT
import sys
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 gui1_support
def vp_start_gui():
'''Starting point when module is the main routine.'''
global val, w, root,gui1_support
root = tk.Tk()
gui1_support.set_Tk_var()
top = Toplevel1 (root)
gui1_support.init(root, top)
root.protocol("WM_DELETE_WINDOW", gui1_support.destroy_window)
root.mainloop()
w = None
def create_Toplevel1(root, *args, **kwargs):
'''Starting point when module is imported by another program.'''
global w, w_win, rt
rt = root
w = tk.Toplevel (root)
gui1_support.main()
gui1_support.set_Tk_var()
top = Toplevel1 (w)
gui1_support.init(w, top, *args, **kwargs)
return (w, top)
def destroy_Toplevel1():
global w
w.destroy()
w = None
class Toplevel1:
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 = '#d9d9d9' # X11 color: 'gray85'
self.style = ttk.Style()
if sys.platform == "win32":
self.style.theme_use('alt')
self.style.configure('.',background=_bgcolor)
self.style.configure('.',foreground=_fgcolor)
self.style.map('.',background=
[('selected', _compcolor), ('active',_ana2color)])
top.geometry("720x451+512+256")
top.title("CommandLauncher")
top.configure(background="#808000")
top.configure(highlightbackground="#4169ef")
top.configure(highlightcolor="#630000")
self.Scrolledtext1 = ScrolledText(top)
self.Scrolledtext1.place(relx=0.0, rely=0.0, relheight=0.98
, relwidth=0.268)
self.Scrolledtext1.configure(background="white")
self.Scrolledtext1.configure(foreground="black")
self.Scrolledtext1.configure(highlightbackground="#d9d9d9")
self.Scrolledtext1.configure(highlightcolor="black")
self.Scrolledtext1.configure(insertbackground="black")
self.Scrolledtext1.configure(insertborderwidth="3")
self.Scrolledtext1.configure(selectbackground="#c4c4c4")
self.Scrolledtext1.configure(selectforeground="black")
self.Scrolledtext1.configure(width=10)
self.Scrolledtext1.configure(wrap='none')
self.Scrolledtext1.config(font=("Helvetica", 12))
self.Scrolledtext1.configure(undo=True)
self.Scrolledtext2 = ScrolledText(top)
self.Scrolledtext2.place(relx=0.267, rely=0.0, relheight=0.357
, relwidth=0.735)
self.Scrolledtext2.configure(background="white")
self.Scrolledtext2.configure(foreground="black")
self.Scrolledtext2.configure(highlightbackground="#d9d9d9")
self.Scrolledtext2.configure(highlightcolor="black")
self.Scrolledtext2.configure(insertbackground="black")
self.Scrolledtext2.configure(insertborderwidth="3")
self.Scrolledtext2.configure(selectbackground="#c4c4c4")
self.Scrolledtext2.configure(selectforeground="black")
self.Scrolledtext2.configure(width=10)
self.Scrolledtext2.configure(wrap='none')
self.Scrolledtext2.config(font=("Helvetica", 12))
self.Scrolledtext2.configure(undo=True)
self.Entry1 = tk.Entry(top)
self.Entry1.place(relx=0.467, rely=0.377,height=24, relwidth=0.28)
self.Entry1.configure(background="white")
self.Entry1.configure(disabledforeground="#a3a3a3")
self.Entry1.configure(font="TkFixedFont")
self.Entry1.configure(foreground="#000000")
self.Entry1.configure(highlightbackground="#d6fff5")
self.Entry1.configure(highlightcolor="#630000")
self.Entry1.configure(highlightthickness="2")
self.Entry1.configure(insertbackground="black")
self.Entry1.configure(selectbackground="#c4c4c4")
self.Entry1.configure(selectforeground="black")
self.Entry1.insert('insert',"Username")
self.Entry1.config(font=("Calibri Light", 12))
self.Entry2 = tk.Entry(top, show="*")
self.Entry2.place(relx=0.467, rely=0.443,height=24, relwidth=0.28)
self.Entry2.configure(background="white")
self.Entry2.configure(disabledforeground="#a3a3a3")
self.Entry2.configure(font="TkFixedFont")
self.Entry2.configure(foreground="#000000")
self.Entry2.configure(highlightbackground="#d6fff5")
self.Entry2.configure(highlightcolor="#630000")
self.Entry2.configure(highlightthickness="2")
self.Entry2.configure(insertbackground="black")
self.Entry2.configure(selectbackground="#c4c4c4")
self.Entry2.configure(selectforeground="black")
self.Entry2.insert('insert',"Username")
self.Entry2.config(font=("Calibri Light", 16))
self.Button1 = tk.Button(top)
self.Button1.place(relx=0.767, rely=0.377, height=54, width=120)
self.Button1.configure(activebackground="#d9d9d9")
self.Button1.configure(activeforeground="#000000")
self.Button1.configure(background="#6acdd8")
self.Button1.configure(command=gui1_support.main)
self.Button1.configure(disabledforeground="#a3a3a3")
self.Button1.configure(foreground="#000000")
self.Button1.configure(highlightbackground="#d9d9d9")
self.Button1.configure(highlightcolor="black")
self.Button1.configure(pady="0")
self.Button1.configure(text='''GO''')
self.Button1.config(font=("Calibri", 17), fg="#FFFFFF")
self.menubar = tk.Menu(top,font="TkMenuFont",bg=_bgcolor,fg=_fgcolor)
top.configure(menu = self.menubar)
self.Scrolledtext3 = ScrolledText(top)
self.Scrolledtext3.place(relx=0.267, rely=0.51, relheight=0.47
, relwidth=0.735)
self.Scrolledtext3.configure(background="white")
self.Scrolledtext3.configure(foreground="black")
self.Scrolledtext3.configure(highlightbackground="#d9d9d9")
self.Scrolledtext3.configure(highlightcolor="black")
self.Scrolledtext3.configure(insertbackground="black")
self.Scrolledtext3.configure(insertborderwidth="3")
self.Scrolledtext3.configure(selectbackground="#c4c4c4")
self.Scrolledtext3.configure(selectforeground="black")
self.Scrolledtext3.configure(width=10)
self.Scrolledtext3.configure(wrap='none')
self.Scrolledtext3.config(font=("Lucida Console", 10))
self.TCombobox1 = ttk.Combobox(top)
self.TCombobox1.place(relx=0.283, rely=0.378, relheight=0.047
, relwidth=0.172)
self.TCombobox1.configure(state='readonly')
self.TCombobox1['values']=('sqlcmd','PSEXEC','Invoke-WmiMethod','Invoke-Command')
self.TCombobox1.configure(textvariable=gui1_support.combobox)
self.TCombobox1.current(0)
self.TCombobox1.configure(width=103)
self.TCombobox1.configure(takefocus="")
self.Entry3 = tk.Entry(top)
self.Entry3.place(relx=0.283, rely=0.444,height=20, relwidth=0.167)
self.Entry3.configure(background="white")
self.Entry3.configure(disabledforeground="#a3a3a3")
self.Entry3.configure(font=("Lucida Console", 10))
self.Entry3.configure(foreground="#000000")
self.Entry3.configure(insertbackground="black")
self.Entry3.configure(width=100)
self.Entry3.insert('insert',"Opts.(Default)")
self.Scrolledtext1.insert("end",'-Hosts-')
self.Scrolledtext2.insert("end",'-Querry-')
self.Scrolledtext3.insert("end",'-Output-')
self.TProgressbar1 = ttk.Progressbar(top)
self.TProgressbar1.place(relx=0, rely=0.98, relwidth=1
, relheight=0.02)
self.TProgressbar1.configure(length="100",mode='determinate',style='frenetic.Horizontal.TProgressbar')
# The following code is added to facilitate the Scrolled widgets you specified.
class AutoScroll(object):
'''Configure the scrollbars for a widget.'''
def __init__(self, master):
# Rozen. Added the try-except clauses so that this class
# could be used for scrolled entry widget for which vertical
# scrolling is not supported. 5/7/14.
try:
vsb = ttk.Scrollbar(master, orient='vertical', command=self.yview)
except:
pass
hsb = ttk.Scrollbar(master, orient='horizontal', command=self.xview)
#self.configure(yscrollcommand=_autoscroll(vsb),
# xscrollcommand=_autoscroll(hsb))
try:
self.configure(yscrollcommand=self._autoscroll(vsb))
except:
pass
self.configure(xscrollcommand=self._autoscroll(hsb))
self.grid(column=0, row=0, sticky='nsew')
try:
vsb.grid(column=1, row=0, sticky='ns')
except:
pass
hsb.grid(column=0, row=1, sticky='ew')
master.grid_columnconfigure(0, weight=1)
master.grid_rowconfigure(0, weight=1)
# Copy geometry methods of master (taken from ScrolledText.py)
if py3:
methods = tk.Pack.__dict__.keys() | tk.Grid.__dict__.keys() \
| tk.Place.__dict__.keys()
else:
methods = tk.Pack.__dict__.keys() + tk.Grid.__dict__.keys() \
+ tk.Place.__dict__.keys()
for meth in methods:
if meth[0] != '_' and meth not in ('config', 'configure'):
setattr(self, meth, getattr(master, meth))
@staticmethod
def _autoscroll(sbar):
'''Hide and show scrollbar as needed.'''
def wrapped(first, last):
first, last = float(first), float(last)
if first <= 0 and last >= 1:
sbar.grid_remove()
else:
sbar.grid()
sbar.set(first, last)
return wrapped
def __str__(self):
return str(self.master)
def _create_container(func):
'''Creates a ttk Frame with a given master, and use this new frame to
place the scrollbars and the widget.'''
def wrapped(cls, master, **kw):
container = ttk.Frame(master)
container.bind('<Enter>', lambda e: _bound_to_mousewheel(e, container))
container.bind('<Leave>', lambda e: _unbound_to_mousewheel(e, container))
return func(cls, container, **kw)
return wrapped
class ScrolledText(AutoScroll, tk.Text):
'''A standard Tkinter Text widget with scrollbars that will
automatically show/hide as needed.'''
@_create_container
def __init__(self, master, **kw):
tk.Text.__init__(self, master, **kw)
AutoScroll.__init__(self, master)
import platform
def _bound_to_mousewheel(event, widget):
child = widget.winfo_children()[0]
if platform.system() == 'Windows' or platform.system() == 'Darwin':
child.bind_all('<MouseWheel>', lambda e: _on_mousewheel(e, child))
child.bind_all('<Shift-MouseWheel>', lambda e: _on_shiftmouse(e, child))
child.bind_all('<Control-a>', lambda e: _select_all(e,child))
child.bind_all('<Control-A>', lambda e: _select_all(e,child))
child.bind_all("<FocusIn>",lambda e:_clear_on_focus(e,child))
else:
child.bind_all('<Button-4>', lambda e: _on_mousewheel(e, child))
child.bind_all('<Button-5>', lambda e: _on_mousewheel(e, child))
child.bind_all('<Shift-Button-4>', lambda e: _on_shiftmouse(e, child))
child.bind_all('<Shift-Button-5>', lambda e: _on_shiftmouse(e, child))
def _unbound_to_mousewheel(event, widget):
if platform.system() == 'Windows' or platform.system() == 'Darwin':
widget.unbind_all('<MouseWheel>')
widget.unbind_all('<Shift-MouseWheel>')
widget.unbind_all('<Control-a>')
widget.unbind_all('<Control-A>')
else:
widget.unbind_all('<Button-4>')
widget.unbind_all('<Button-5>')
widget.unbind_all('<Shift-Button-4>')
widget.unbind_all('<Shift-Button-5>')
def _on_mousewheel(event, widget):
if platform.system() == 'Windows':
widget.yview_scroll(-1*int(event.delta/120),'units')
elif platform.system() == 'Darwin':
widget.yview_scroll(-1*int(event.delta),'units')
else:
if event.num == 4:
widget.yview_scroll(-1, 'units')
elif event.num == 5:
widget.yview_scroll(1, 'units')
def _on_shiftmouse(event, widget):
if platform.system() == 'Windows':
widget.xview_scroll(-1*int(event.delta/120), 'units')
elif platform.system() == 'Darwin':
widget.xview_scroll(-1*int(event.delta), 'units')
else:
if event.num == 4:
widget.xview_scroll(-1, 'units')
elif event.num == 5:
widget.xview_scroll(1, 'units')
def _select_all(event,widget):
event.widget.tag_add("sel","1.0","end")
global interactions
interactions=[]
def _clear_on_focus(event,widget):
from gui1_support import first_run
try:
event.widget.delete(first=0,last=100)
except:
if str(event.widget) not in interactions and first_run:
event.widget.delete(1.0,"end")
interactions.append(str(event.widget))
pass
if __name__ == '__main__':
vp_start_gui()