-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui_parent_view.py
More file actions
414 lines (302 loc) · 16.2 KB
/
ui_parent_view.py
File metadata and controls
414 lines (302 loc) · 16.2 KB
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
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
'''
Created on 20 May, 2018
@author: sp977u@att.com (Satish Palnati)
'''
from PySide import QtGui
from PySide import QtCore
import os
import logos
from PySide.QtCore import Signal
from PySide.QtGui import QWidget,QFrame, QHBoxLayout, QVBoxLayout, QMainWindow, QLabel
from views.common.extract_view import extract_excel
from views import validate_inputs
from views.common.left_base_view import left_base
from views.common.get_view import get_controls
from views.common.push_view import push_controls
from views.common.compare_view import compare_op_results
import time
from asyncio.tasks import sleep
class Ui_MainView(QMainWindow):
gui_methods_sig = Signal(int,)
def __init__(self,):
super(Ui_MainView, self).__init__()
self.output_folder = os.getcwd()
self.usr = ''
self.psw = ''
self.save_username_checked = False
self.right_base_layout_v = QtGui.QVBoxLayout()
self.msgBox = QtGui.QMessageBox()
self.validations = validate_inputs.validate_controls(self) # instance for input validations and we are passing self to validate class for model updations
def gifUI(self,gui_slate):
self.gui = gui_slate
self.gif_widget = QWidget()
self.gif_layout = QVBoxLayout()
self.movie_screen = QLabel()
self.movie_screen.setSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)
self.movie_screen.setAlignment(QtCore.Qt.AlignCenter)
self.gif_layout.addWidget(self.movie_screen)
ag_file = "GIF-180704_103026.gif"
self.movie = QtGui.QMovie(ag_file, QtCore.QByteArray(), self.gif_widget)
self.movie.setCacheMode(QtGui.QMovie.CacheAll)
self.movie.setSpeed(75)
self.movie_screen.setMovie(self.movie)
# self.movie_screen.setFixedWidth(500)
self.gif_widget.setLayout(self.gif_layout)
self.gui.setCentralWidget(self.gif_widget)
# self.gui.addDockWidget(self.gif_widget)
self.movie.start()
# self.movie.setPaused(True)
self.gif_widget.show()
# time.sleep(2)
# self.movie.stop()
def setupUi(self,gui_slate):
self.gui = gui_slate
self.gui.get_option_selected = False
self.gui.push_option_selected = False
self.gui.extract_opt_selected = False
self.gui.compare_opt_selected = False
#Outer most Main Layout
self.widget = QWidget()
self.widget.setMinimumSize(850,600)
self.main_layout_h = QHBoxLayout()
self.main_layout_h.setAlignment(QtCore.Qt.AlignTop)
self.widget.setLayout(self.main_layout_h)
self.gui.setCentralWidget(self.widget)
self.left_base_widget = QWidget()
# self.left_base_widget.setMaximumWidth(600)
# self.left_base_widget.setMinimumWidth(450)
# self.left_base_widget.setMaximumHeight(700)
self.right_base_widget = QWidget()
#3 Sub main Layouts
self.left_base_layout_v = QVBoxLayout()
# self.right_base_layout_v = QVBoxLayout()
self.corner_logo_layout_v = QVBoxLayout()
self.left_base_layout_v.setAlignment(QtCore.Qt.AlignTop)
self.right_base_layout_v.setAlignment(QtCore.Qt.AlignTop)
#Added Widgets and layouts to the outermost layout
self.main_layout_h.addWidget(self.left_base_widget)
self.main_layout_h.addWidget(self.right_base_widget)
self.main_layout_h.addLayout(self.corner_logo_layout_v)
# , QtGui.QFont.Normal
self.grp_heading_font = QtGui.QFont("Verdana", 10)
self.grp_heading_font.setItalic(True)
#Radio buttons layout
self.radio_groupBox = QtGui.QGroupBox()
self.radio_option_layout_lb_h = QHBoxLayout()
self.radio_groupBox.setLayout(self.radio_option_layout_lb_h)
self.radio_groupBox.setMinimumWidth(450)
self.left_base_layout_v.addWidget(self.radio_groupBox)
#Credentials layouts
self.credentials_groupbox = QtGui.QGroupBox("GTAC Credentials")
self.credentials_groupbox.setFont(self.grp_heading_font)
self.credentials_layout_lb_v = QVBoxLayout()
self.username_layout_lb_h = QHBoxLayout()
self.password_layout_lb_h = QHBoxLayout()
self.cr_layout_lb_h = QHBoxLayout()
self.password_layout_lb_h.setAlignment(QtCore.Qt.AlignLeft)
self.credentials_layout_lb_v.addLayout(self.username_layout_lb_h)
self.credentials_layout_lb_v.addLayout(self.password_layout_lb_h)
self.credentials_layout_lb_v.addLayout(self.cr_layout_lb_h)
self.credentials_groupbox.setLayout(self.credentials_layout_lb_v)
self.left_base_layout_v.addWidget(self.credentials_groupbox)
self.credentials_groupbox.setAlignment(QtCore.Qt.AlignLeft)
self.credentials_groupbox.hide()
#IP group box layouts
self.IP_groupBox = QtGui.QGroupBox("IP Inputs")
self.IP_groupBox.setFont(self.grp_heading_font)
self.ip_file_layout_lb_v = QVBoxLayout()
self.ip_file_select_layout_lb_h = QHBoxLayout()
self.ip_file_select_layout_lb_h.setAlignment(QtCore.Qt.AlignLeft)
self.ip_file_layout_lb_v.addLayout(self.ip_file_select_layout_lb_h)
self.IP_groupBox.setMaximumHeight(135)
self.IP_groupBox.setLayout(self.ip_file_layout_lb_v)
self.left_base_layout_v.addWidget(self.IP_groupBox)
self.IP_groupBox.hide()
# Commands group box selection
self.Commands_groupBox = QtGui.QGroupBox("Commands Inputs")
self.Commands_groupBox.setFont(self.grp_heading_font)
self.commands_label_layout_lb_v = QVBoxLayout()
self.default_chkbx_layout_lb_h = QHBoxLayout()
self.commands_file_layout_lb_h = QHBoxLayout()
self.commands_file_layout_lb_h.setAlignment(QtCore.Qt.AlignLeft)
self.commands_custom_box_layout_lb_h = QHBoxLayout()
self.none_radio_btn_layout_lb_h = QHBoxLayout()
self.commands_label_layout_lb_v.addLayout(self.default_chkbx_layout_lb_h)
self.commands_label_layout_lb_v.addLayout(self.commands_file_layout_lb_h)
self.commands_label_layout_lb_v.addLayout(self.commands_custom_box_layout_lb_h)
self.commands_label_layout_lb_v.addLayout(self.none_radio_btn_layout_lb_h)
self.Commands_groupBox.setMaximumHeight(225)
self.Commands_groupBox.setAlignment(QtCore.Qt.AlignLeft)
self.Commands_groupBox.setLayout(self.commands_label_layout_lb_v)
self.left_base_layout_v.addWidget(self.Commands_groupBox)
self.Commands_groupBox.hide()
# results group box
self.results_groupBox = QtGui.QGroupBox("Results")
self.results_groupBox.setFont(self.grp_heading_font)
self.results_layout_lb_v = QVBoxLayout()
self.output_layout_lb_h = QHBoxLayout()
self.output_layout_lb_h.setAlignment(QtCore.Qt.AlignLeft)
self.results_layout_lb_v.addLayout(self.output_layout_lb_h)
self.results_groupBox.setLayout(self.results_layout_lb_v)
self.left_base_layout_v.addWidget(self.results_groupBox)
self.results_groupBox.hide()
# Go Button
self.go_btn_layout_lb_h = QHBoxLayout()
self.left_base_layout_v.addLayout(self.go_btn_layout_lb_h)
# Right and Left Widget on individual layouts
self.left_base_widget.setLayout(self.left_base_layout_v)
self.right_base_widget.setLayout(self.right_base_layout_v)
#### just to see right base layout
self.right_base = QtGui.QTextEdit(self.gui)
self.right_base.setStyleSheet("""QToolTip { background-color: #00bfff; color: black; border: black solid 2px }""")
self.right_base.setObjectName("IP_Address")
self.right_base_layout_v.addWidget(self.right_base)
# self.right_base.setMaximumHeight(500)
self.right_base.hide()
self.snap_gif = QtGui.QLabel(self.gui)
self.snap_gif.setText("")
self.snap_gif.setStyleSheet("background-color: None")
self.snap_gif.setPixmap(QtGui.QPixmap("Capture.png"))
self.snap_gif.setObjectName("logo_corner")
self.right_base_layout_v.addWidget(self.snap_gif)
######
self.gui.setWindowTitle('SPEED + 3.0')
self.gui.setWindowIcon(QtGui.QIcon(":/logo/Wind_icon.png"))
self.gui.setAutoFillBackground(True)
self.corner_logolabel = QtGui.QLabel(self.gui)
self.corner_logolabel.setText("")
self.corner_logolabel.setStyleSheet("background-color: None")
self.corner_logolabel.setPixmap(QtGui.QPixmap(":/logo/ATT-LOGO-2.png"))
self.corner_logolabel.setObjectName("logo_corner")
# self.corner_logo_layout_v.setAlignment(QtCore.Qt.AlignTop)
self.corner_logo_layout_v.setAlignment(int(QtCore.Qt.AlignTop | QtCore.Qt.AlignRight))
self.corner_logo_layout_v.addWidget(self.corner_logolabel)
self.msgBox.setWindowIcon(QtGui.QIcon(":/logo/Wind_icon.png"))
self.msgBox.setFont(QtGui.QFont("Verdana", 8, QtGui.QFont.Normal))
self.make_menu()
## gif at&t logo
# self.movie_screen = QLabel()
# self.movie_screen.setSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)
# self.movie_screen.setAlignment(QtCore.Qt.AlignCenter)
# self.right_base_layout_v.addWidget(self.movie_screen)
#
# ag_file = "C:/Users/rg012f/eclipse-workspace/poojan_try/giphy.gif"
# self.movie = QtGui.QMovie(ag_file, QtCore.QByteArray(), None)
# self.movie.setCacheMode(QtGui.QMovie.CacheAll)
# self.movie.setSpeed(75)
# self.movie_screen.setMovie(self.movie)
#
#
# self.movie.setPaused(True)
# self.movie.start()
# self.right_base_widget.show()
# time.sleep(2)
######################### order of the below funtion calls is importnant change them wisely#####################
self.check_save_username()
self.create_views()
self.left_radio_controls()
self.connect_child_views()
def make_menu(self):
self.myMenu = self.gui.menuBar()
self.file = self.myMenu.addMenu('&File')
self.file.addAction("&Select Output Folder...",self.select_destination, "Ctrl+O")
self.file.addAction("&Exit",self.closewindow, "Ctrl+X")
self.file = self.myMenu.addMenu('&Help')
self.file.addAction("&About...",self.about_tool, "Ctrl+H")
def check_save_username(self):
print("Yo reached save username")
try:
f = open('Username.txt','r')
lines = f.readlines()
if len(lines):
self.save_username_checked = True
else:
self.save_username_checked = False
except Exception as ex:
print(ex)
def select_destination(self, ):
fld = QtGui.QFileDialog.getExistingDirectory(self.gui, 'Select Output Folder')
self.output_folder = str(fld)
def closewindow(self):
self.gui.close()
def about_tool(self):
abouttool = "Speed + v3.0 \n\nThis tool is useful to fetch, push, extract, compare device configs \n"
self.msgBox.setText(abouttool)
self.msgBox.setWindowTitle("About Speed +")
self.msgBox.show()
def left_radio_controls(self):
# ============================ main radio options selection :
radio_font = QtGui.QFont("Verdana", 10, QtGui.QFont.Normal)
self.get_radio_option = QtGui.QRadioButton(self.gui)
self.get_radio_option.setFont(radio_font)
self.get_radio_option.setText("Get")
self.radio_option_layout_lb_h.addWidget(self.get_radio_option)
self.push_radio_option = QtGui.QRadioButton(self.gui)
self.push_radio_option.setFont(radio_font)
self.push_radio_option.setText("Push")
self.radio_option_layout_lb_h.addWidget(self.push_radio_option)
self.extract_radio_option = QtGui.QRadioButton(self.gui)
self.extract_radio_option.setFont(radio_font)
self.extract_radio_option.setText("Extract")
self.radio_option_layout_lb_h.addWidget(self.extract_radio_option)
self.compare_radio_option = QtGui.QRadioButton(self.gui)
self.compare_radio_option.setFont(radio_font)
self.compare_radio_option.setText("Compare")
self.radio_option_layout_lb_h.addWidget(self.compare_radio_option)
def disp_get_options(self):
self.snap_gif.show()
self.push_view.hide_push()
self.excel_view.userOptionextract.hide()
self.compare_view.main_widget.hide()
self.get_view.display_get()
def disp_push_options(self):
self.snap_gif.show()
self.get_view.hide_get()
self.excel_view.userOptionextract.hide()
self.compare_view.main_widget.hide()
self.push_view.display_push()
self.validations.hide_right_common()
def disp_ext_options(self):
self.get_view.hide_get()
self.push_view.hide_push()
self.compare_view.main_widget.hide()
self.excel_view.display_excel_portion()
self.validations.hide_right_common()
def disp_comp_options(self):
self.get_view.hide_get()
self.push_view.hide_push()
self.excel_view.userOptionextract.hide()
self.compare_view.display_comapre_portion()
self.validations.hide_right_common()
def connect_child_views(self):
self.get_radio_option.clicked.connect(self.disp_get_options)
self.push_radio_option.clicked.connect(self.disp_push_options)
self.extract_radio_option.clicked.connect(self.disp_ext_options)
self.compare_radio_option.clicked.connect(self.disp_comp_options)
self.base_left.go_button.clicked.connect(self.connect_validate_option)
def connect_validate_option(self):
self.validations.validate_user_inputs() # passing self to validation class method , other end this self is last_parent
def create_views(self):
self.base_left = left_base(self) # we are passing main GUI and also local self as 'last_parent' to left base view to update variables
self.get_view = get_controls(self.gui,self.base_left)
self.push_view = push_controls(self.gui,self.base_left)
self.excel_view = extract_excel(self.gui,self.base_left)
self.compare_view = compare_op_results(self)
def show_gif_right_base(self,path,layout):
print("ui parent view show_gif_right_base line 394")
self.movie_screen = QLabel()
self.movie_screen.setSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)
self.movie_screen.setAlignment(QtCore.Qt.AlignCenter)
layout.addWidget(self.movie_screen)
ag_file = path
self.movie = QtGui.QMovie(ag_file, QtCore.QByteArray(), None)
self.movie.setCacheMode(QtGui.QMovie.CacheAll)
self.movie.setSpeed(75)
self.movie_screen.setMovie(self.movie)
#"C:/Users/rg012f/eclipse-workspace/poojan_try/giphy.gif"
self.movie.setPaused(True)
self.movie.start()
# self.right_base_widget.setLayout(layout)
# self.right_base_widget.show()
def hide_gif_right_base(self):
self.movie_screen.hide()