-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
706 lines (637 loc) · 29.2 KB
/
main.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
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
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
import time
from xml.etree.ElementTree import ElementTree
import PyQt5
from PyQt5 import QtGui, QtCore, QtWidgets
from PyQt5.QtCore import QTimer
from PyQt5.QtGui import QPixmap, QGuiApplication, QIcon
from PyQt5.QtWidgets import QMainWindow, QApplication, QSplashScreen, QFileDialog, QListWidgetItem, QListWidget
from DeployHelper import Ui_DeployHelper
from AddDeploy import Ui_AddDeploy
import sys
from xml.etree import ElementTree as ET
import functions
# OPEN THE MAIN WINDOW
class Main(QMainWindow, Ui_DeployHelper):
def __init__(self):
super(Main, self).__init__()
self.setupUi(self)
self.populateDeploysList(False)
self.groupBox.hide()
# POPULATE AND SHOW GROUPBOX WITH DEPLOY INFO WHEN A DEPLOY ITEM IS SELECTED
self.listWidget_Deploys.itemClicked.connect(self.populateAndShowGroupBox)
# BUTTON Btn_StartDeploy ACTION
self.Btn_StartDeploy.clicked.connect(self.runDeploy)
# HIDE label_ResultDeploy
self.label_ResultDeploy.hide()
# MAIN WINDOW close event. NOT RENAME (OVERRIDE)
def closeEvent(self, event):
can_exit = True
if can_exit:
self.lineEdit_DeployName.clear()
self.lineEdit_DestPath.clear()
self.textEdit_SourceFiles.clear()
self.label_ResultDeploy.hide()
self.groupBox.hide()
event.accept() # let the window close
else:
event.ignore()
def populateDeploysList(self, updateList):
if updateList:
self.listWidget_Deploys.clear()
# COLLECT ALL DEPLOYS NODES OF XML
tree = ElementTree()
root = tree.parse("Deploys.xml")
# GET ALL NODE 'DEPLOY' OF XML
allDeploys = root.findall('.//deploy')
for node in allDeploys:
deploy_name = node.get('name')
newQListItem = QListWidgetItem()
newQListItem.setText(deploy_name)
self.listWidget_Deploys.addItem(newQListItem)
def populateAndShowGroupBox(self):
# GET THE NAME OF SELECTED DEPLOY
selected_deploy = self.listWidget_Deploys.selectedItems()[0].text()
# GET THE DEPLOY INFO
deploy_info = self.getDeployInfoByName(selected_deploy)
#print(str(deploy_info))
# CLEAR GROUPBOX FIELDS
self.lineEdit_DeployName.clear()
self.textEdit_SourceFiles.clear()
self.lineEdit_DestPath.clear()
# POPULATE GROUP BOX FILEDS WITH DATA OF SELECTED DEPLOY
self.lineEdit_DeployName.setText(deploy_info['name'])
for source_file in deploy_info['source_files']:
self.textEdit_SourceFiles.append(source_file)
self.lineEdit_DestPath.setText(deploy_info['destination_path'])
# SHOW GROUP BOX
self.groupBox.show()
def getDeployInfoByName(self, deploy_name):
try:
deploy_info = {"name": "", "source_files": [], "destination_path": "", 'name': deploy_name}
# COLLECT ALL DEPLOYS NODES OF XML
tree = ElementTree()
root = tree.parse("Deploys.xml")
# GET THE DEPLOY NODE BY NAME
deploy_node = root.find('.//deploy[@name="' + deploy_name + '"]')
if deploy_node is not None:
source_files_nodes = deploy_node.findall('.//sourceFilePath')
for source in source_files_nodes:
deploy_info['source_files'].append(source.text)
destination_path_node = deploy_node.find('.//destinationPath')
if destination_path_node is not None:
deploy_info['destination_path'] = destination_path_node.text
except Exception as error:
print(str(error))
return deploy_info
def runDeploy(self):
#GET SELECTED DEPLOY
selected_deploy = self.listWidget_Deploys.selectedItems()[0].text()
deploy_info = self.getDeployInfoByName(selected_deploy)
# RUN COPY FILES
result = functions.copyFilesToDir(deploy_info['source_files'], deploy_info['destination_path'])
self.showDeployResultMessage(result)
def showDeployResultMessage(self, result):
if result['error'] is True:
# message for dark theme
if self.Btn_ChangeTheme.text() == 'Light':
self.label_ResultDeploy.setStyleSheet("""
font-family: "Lucida Console", "Courier New", monospace;
font-size: 15px;
color:#ff5900;
""")
# message for light theme
else:
self.label_ResultDeploy.setStyleSheet("""
font-family: "Lucida Console", "Courier New", monospace;
font-size: 15px;
color:red;
""")
else:
# message for dark theme
if self.Btn_ChangeTheme.text() == 'Light':
self.label_ResultDeploy.setStyleSheet("""
font-family: "Lucida Console", "Courier New", monospace;
font-size: 15px;
color:#00ff00;
""")
#message for light theme
else:
self.label_ResultDeploy.setStyleSheet("""
font-family: "Lucida Console", "Courier New", monospace;
font-size: 15px;
color:green;
""")
self.label_ResultDeploy.setText(result['message'])
self.label_ResultDeploy.show()
def changeTheme(self):
# SWITCH FROM DARK TO LIGHT
if self.Btn_ChangeTheme.text() == 'Light':
#region SWITCH MAIN WINDOW TO LIGHT
self.label.setStyleSheet('''
font-family: "Lucida Console", "Courier New", monospace;
color:black;
''')
self.label_2.setStyleSheet('''
font-family: "Lucida Console", "Courier New", monospace;
color:black;
''')
self.label_3.setStyleSheet('''
font-family: "Lucida Console", "Courier New", monospace;
color:black;
''')
self.label_4.setStyleSheet('''
font-family: "Lucida Console", "Courier New", monospace;
color:black;
''')
self.listWidget_Deploys.setStyleSheet('''
QListWidget {
border: 2px solid #0092d1;
/*border: 2px solid white;*/
border-radius: 5px;
padding: 0 8px;
selection-background-color: darkgray;
font-family: "Lucida Console", "Courier New", monospace;
}
QListWidget::item:selected {
border : 0px solid black;
background : #0092d1;
/*background : #9ca2ad;*/
border-radius: 1px;
color:white;
font-family: "Lucida Console", "Courier New",monospace;
}
QListWidget::item {
border : 0px solid black;
font-family: "Lucida Console", "Courier New",monospace;
color:black;
}
''')
self.groupBox.setStyleSheet('''
QGroupBox {
border: 2px solid #0092d1;
/*border: 2px solid white;*/
border-radius: 5px;
padding: 0 8px;
selection-background-color: darkgray;
font-family: "Lucida Console", "Courier New", monospace;
color:black;
font-size: 15px;
}
''')
self.lineEdit_DeployName.setStyleSheet('''
border: 1px solid #0092d1;
border-radius: 5px;
padding: 0 8px;
background: white;
selection-background-color: darkgray;
font-family: "Lucida Console", "Courier New", monospace;
font-size: 14px;
''')
self.textEdit_SourceFiles.setStyleSheet('''
QTextEdit {
border: 1px solid #0092d1;
border-radius: 5px;
padding: 0 8px;
background: white;
selection-background-color: darkgray;
font-family: "Lucida Console", "Courier New", monospace;
font-size: 14px;
}
''')
self.lineEdit_DestPath.setStyleSheet('''
QLineEdit {
border: 1px solid #0092d1;
border-radius: 5px;
padding: 0 8px;
background: white;
selection-background-color: #2c509e;
font-family: "Lucida Console", "Courier New", monospace;
font-size: 14px;
}
''')
self.setStyleSheet('')
self.Btn_ChangeTheme.setText('Dark')
#endregion
#region SWITCH AddDeploy WINDOW TO LIGHT
#endregion
# SWITCH FROM LIGHT TO DARK
else:
#region SWITCH MAIN WINDOW TO DARK
self.setStyleSheet('background-color:#364052;')
self.label.setStyleSheet('''
font-family: "Lucida Console", "Courier New", monospace;
color:white;
''')
self.label_2.setStyleSheet('''
font-family: "Lucida Console", "Courier New", monospace;
color:white;
''')
self.label_3.setStyleSheet('''
font-family: "Lucida Console", "Courier New", monospace;
color:white;
''')
self.label_4.setStyleSheet('''
font-family: "Lucida Console", "Courier New", monospace;
color:white;
''')
self.listWidget_Deploys.setStyleSheet('''
QListWidget {
/*border: 2px solid #0092d1;*/
border: 2px solid white;
border-radius: 5px;
padding: 0 8px;
selection-background-color: darkgray;
font-family: "Lucida Console", "Courier New", monospace;
}
QListWidget::item:selected {
border : 0px solid black;
background : #0092d1;
border-radius: 1px;
/*background : #9ca2ad;*/
color:white;
font-family: "Lucida Console", "Courier New",monospace;
}
QListWidget::item {
border : 0px solid black;
font-family: "Lucida Console", "Courier New",monospace;
color:white;
}
''')
self.lineEdit_DeployName.setStyleSheet('''
/*border: 1px solid #0092d1;*/
border: 0px solid #0092d1;
border-radius: 5px;
padding: 0 8px;
background: white;
selection-background-color: darkgray;
font-family: "Lucida Console", "Courier New", monospace;
font-size: 14px;
''')
self.textEdit_SourceFiles.setStyleSheet('''
QTextEdit {
/* border: 1px solid #0092d1;*/
border: 0px solid #0092d1;
border-radius: 5px;
padding: 0 8px;
background: white;
selection-background-color: darkgray;
font-family: "Lucida Console", "Courier New", monospace;
font-size: 14px;
}
''')
self.lineEdit_DestPath.setStyleSheet('''
QLineEdit {
/*border: 1px solid #0092d1;*/
border: 0px solid #0092d1;
border-radius: 5px;
padding: 0 8px;
background: white;
selection-background-color: #2c509e;
font-family: "Lucida Console", "Courier New", monospace;
font-size: 14px;
}
''')
self.groupBox.setStyleSheet('''
QGroupBox {
/* border: 2px solid #0092d1;*/
border: 2px solid white;
border-radius: 5px;
padding: 0 8px;
selection-background-color: darkgray;
font-family: "Lucida Console", "Courier New", monospace;
color:white;
font-size: 15px;
}
''')
self.Btn_ChangeTheme.setText('Light')
# endregion
class AddDeployWindow(QMainWindow, Ui_AddDeploy):
def __init__(self):
super(AddDeployWindow, self).__init__()
self.setupUi(self)
# BUTTON Btn_SelectSourceFiles CLICK EVENT
self.Btn_SelectSourceFiles.clicked.connect(self.selectSourceFiles)
# BUTTON Btn_SelectDestinationPath CLICK EVENT
self.Btn_SelectDestinationPath.clicked.connect(self.selectDestinationPath)
# BUTTON Btn_SaveDeploy CLICK EVENT
self.Btn_SaveDeploy.clicked.connect(self.saveDeployAction)
# SET ERROR LABEL TO HIDDEN
self.label_ErrorSaveDeploy.hide()
def OPEN(self):
if main.Btn_ChangeTheme.text() == 'Dark':
#region SET LIGHT THEME TO AddDeploy WINDW
self.label.setStyleSheet('font-family: "Lucida Console", "Courier New", monospace;')
self.label_2.setStyleSheet('font-family: "Lucida Console", "Courier New", monospace;')
self.label_3.setStyleSheet('font-family: "Lucida Console", "Courier New", monospace;')
self.Btn_SelectSourceFiles.setIcon(QIcon("./icons/icons8-add-file-48.png"))
self.Btn_SelectSourceFiles.setStyleSheet('''
QPushButton {
border: 1px solid #0092d1;
border-radius: 6px;
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #f6f7fa, stop: 1 #dadbde);
min-width: 80px;
font-family: "Lucida Console", "Courier New", monospace;
}
QPushButton:pressed {
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #dadbde, stop: 1 #f6f7fa);
}
QPushButton:flat {
border: none; /* no border for a flat push button */
}
QPushButton:default {
border-color: navy; /* make the default button prominent */
}
''')
self.Btn_SelectDestinationPath.setIcon(QIcon("./icons/icons8-folder-48.png"))
self.Btn_SelectDestinationPath.setStyleSheet('''
QPushButton {
border: 1px solid #0092d1;
border-radius: 6px;
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #f6f7fa, stop: 1 #dadbde);
min-width: 80px;
font-family: "Lucida Console", "Courier New", monospace;
}
QPushButton:pressed {
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #dadbde, stop: 1 #f6f7fa);
}
QPushButton:flat {
border: none; /* no border for a flat push button */
}
QPushButton:default {
border-color: navy; /* make the default button prominent */
}
''')
self.textEdit_SourceFiles.setStyleSheet('''
QTextEdit {
border: 1px solid #0092d1;
border-radius: 5px;
padding: 0 8px;
background: white;
selection-background-color: darkgray;
font-family: "Lucida Console", "Courier New", monospace;
}
''')
self.lineEdit_DestPath.setStyleSheet('''
QLineEdit {
border: 1px solid #0092d1;
border-radius: 5px;
padding: 0 8px;
background: white;
selection-background-color: #2c509e;
font-family: "Lucida Console", "Courier New", monospace;
}
''')
self.lineEdit_DeployName.setStyleSheet('''
QLineEdit {
border: 1px solid #0092d1;
border-radius: 5px;
padding: 0 8px;
background: white;
selection-background-color: darkgray;
font-family: "Lucida Console", "Courier New", monospace;
}
''')
self.setStyleSheet('')
#endregion
else:
# region SET DARK THEME TO AddDeploy WINDOW
self.label.setStyleSheet('''
font-family: "Lucida Console", "Courier New", monospace;
color:white;
''')
self.label_2.setStyleSheet('''
font-family: "Lucida Console", "Courier New", monospace;
color:white;
''')
self.label_3.setStyleSheet('''
font-family: "Lucida Console", "Courier New", monospace;
color:white;
''')
self.Btn_SelectSourceFiles.setIcon(QIcon("./icons/icons8-add-file-48.png"))
self.Btn_SelectSourceFiles.setStyleSheet('''
QPushButton {
border: 0px solid black;
border-radius: 6px;
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #f6f7fa, stop: 1 #dadbde);
min-width: 80px;
font-family: "Lucida Console", "Courier New", monospace;
}
QPushButton:pressed {
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #dadbde, stop: 1 #f6f7fa);
}
QPushButton:flat {
border: none; /* no border for a flat push button */
}
QPushButton:default {
border-color: navy; /* make the default button prominent */
}
''')
self.Btn_SelectDestinationPath.setIcon(QIcon("./icons/icons8-folder-48.png"))
self.Btn_SelectDestinationPath.setStyleSheet('''
QPushButton {
border: 0px solid #0092d1;
border-radius: 6px;
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #f6f7fa, stop: 1 #dadbde);
min-width: 80px;
font-family: "Lucida Console", "Courier New", monospace;
}
QPushButton:pressed {
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #dadbde, stop: 1 #f6f7fa);
}
QPushButton:flat {
border: none; /* no border for a flat push button */
}
QPushButton:default {
border-color: navy; /* make the default button prominent */
}
''')
self.textEdit_SourceFiles.setStyleSheet('''
QTextEdit {
border: 0px solid #0092d1;
border-radius: 5px;
padding: 0 8px;
background: white;
selection-background-color: darkgray;
font-family: "Lucida Console", "Courier New", monospace;
}
''')
self.lineEdit_DestPath.setStyleSheet('''
QLineEdit {
border: 0px solid #0092d1;
border-radius: 5px;
padding: 0 8px;
background: white;
selection-background-color: #2c509e;
font-family: "Lucida Console", "Courier New", monospace;
}
''')
self.lineEdit_DeployName.setStyleSheet('''
QLineEdit {
border: 0px solid #0092d1;
border-radius: 5px;
padding: 0 8px;
background: white;
selection-background-color: #2c509e;
font-family: "Lucida Console", "Courier New", monospace;
}
''')
self.setStyleSheet('background-color:#364052;')
#endregion
main.close()
self.show()
# AddDploy Close event. NOT RENAME (OVERRIDE)
def closeEvent(self, event):
can_exit = True
if can_exit:
self.textEdit_SourceFiles.clear()
self.lineEdit_DestPath.clear()
self.lineEdit_DeployName.clear()
self.label_ErrorSaveDeploy.hide()
main.populateDeploysList(True)
main.show()
event.accept() # let the window close
else:
event.ignore()
# OPEN THE FILE EXPLORER TO SELECT SOURCE FILES
def selectSourceFiles(self):
options = QFileDialog.Options()
#options |= QFileDialog.DontUseNativeDialog
file_names, _ = QFileDialog.getOpenFileNames(None, "Select Files", "", "All Files (*);;Python Files (*.py)",
options=options)
# self.textEdit_SourceFiles.setText(fileName)
# print(file_names)
for file in file_names:
self.textEdit_SourceFiles.append(file)
# OPEN THE FILE EXPLORER TO SELECT THE DESTINATION PATH
def selectDestinationPath(self):
options = QFileDialog.Options()
#options |= QFileDialog.DontUseNativeDialog
dest_path = str(QFileDialog.getExistingDirectory(self, "Select Directory", "", options=options))
self.lineEdit_DestPath.setText(dest_path)
# Btn_SaveDeploy ACTION (SAVE DEPLOY ON XML FILE AND CLOSE AddDeployWindow)
def saveDeployAction(self):
try:
dest_path = self.lineEdit_DestPath.text()
deploy_name = self.lineEdit_DeployName.text()
source_files = self.textEdit_SourceFiles.toPlainText()
source_files_arr = source_files.splitlines()
# CHECK INSERTED VALUES
if (not dest_path) or (not deploy_name) or (not source_files_arr):
self.showErrorMessage(True, 'Please fill in all fields')
else:
self.label_ErrorSaveDeploy.hide()
saveResult = self.saveDeployOnXml(dest_path, deploy_name, source_files_arr)
if saveResult == 0: # ERROR 0: ALREADY EXISTS A DEPLOY NODE WITH THE SAME NAME
self.showErrorMessage(True, 'Deploy not saved: already exists a deploy with the same name')
else:
self.showErrorMessage(False, 'Deploy Saved')
except Exception as error:
print(str(error))
def showErrorMessage(self, error, message):
if error:
# message for dark theme
if main.Btn_ChangeTheme.text() == 'Light':
self.label_ErrorSaveDeploy.setStyleSheet("""
font-family: "Lucida Console", "Courier New", monospace;
font-size: 15px;
color:#ff5900;
""")
# message for light theme
else:
self.label_ErrorSaveDeploy.setStyleSheet("""
font-family: "Lucida Console", "Courier New", monospace;
font-size: 15px;
color:red;
""")
else:
# message for dark theme
if main.Btn_ChangeTheme.text() == 'Light':
self.label_ErrorSaveDeploy.setStyleSheet("""
font-family: "Lucida Console", "Courier New", monospace;
font-size: 15px;
color:#00ff00;
""")
# message for light theme
else:
self.label_ErrorSaveDeploy.setStyleSheet("""
font-family: "Lucida Console", "Courier New", monospace;
font-size: 15px;
color:green;
""")
self.label_ErrorSaveDeploy.setText(message)
self.label_ErrorSaveDeploy.show()
def saveDeployOnXml(self, dest_path, deploy_name, source_files_arr):
try:
# COLLECT ALL DEPLOYS ELEMENT OF XML
tree = ElementTree()
root = tree.parse("Deploys.xml")
# CHECK IF EXISTS A DEPLOY NODE WITH SAME NAME
check_exists = root.find('.//deploy[@name="' + deploy_name + '"]')
if check_exists != None:
return 0
# CREATE NEW DEPLOY ELEMENT OF XML
deploys_node = root.find('.//deploys') # FIND THE NODE NAMED 'deploys'
new_deploy_node = ET.SubElement(deploys_node, 'deploy')
new_deploy_node.set('name', deploy_name)
'''
prova = [elem.tag for elem in deploys_node.iter() if elem is not deploys_node]
for pr in prova:
print(str(pr))
'''
# ADD SOURCE PATH FILES SUB-NODES TO THE NEW DEPLOY NODE
for path in source_files_arr:
path_node = ET.SubElement(new_deploy_node, 'sourceFilePath')
path_node.text = path
# ADD DESTINATION PATH SUB-NODE TO THE NEW DEPLOY NODE
destPath_node = ET.SubElement(new_deploy_node, 'destinationPath')
destPath_node.text = dest_path
# SAVE XML
tree = ET.ElementTree(root)
tree.write("Deploys.xml")
except Exception as error:
print("Error: " + str(error))
def get_resolution():
app = QtWidgets.QApplication(sys.argv)
print(app.primaryScreen())
d = app.desktop()
print(d.screenGeometry())
print(d.availableGeometry())
print(d.screenCount())
g = d.screenGeometry()
return (g.width(), g.height())
if __name__ == "__main__":
x, y = get_resolution()
if x > 1920 and y > 1080:
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True)
else:
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, False)
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, False)
app = QApplication(sys.argv)
# prepare setting screen
pixmap = QPixmap("splash.png")
screen = QGuiApplication.primaryScreen()
#screen = QGuiApplication.screens()[1]
splash = QSplashScreen(screen, pixmap)
# end setting splash screen
main = Main()
ShowAddDeploy = AddDeployWindow() #prepare main window
splash.show() # show the splash screen
time.sleep(5) # wait 5 seconds before close splash screen
splash.close()
main.show()
# BUTTON AddDeploy CLICK EVENT
main.Btn_AddDeploy.clicked.connect(ShowAddDeploy.OPEN)
# BUTTON Btn_ChangeTheme CLICK EVENT
main.Btn_ChangeTheme.clicked.connect(main.changeTheme)
#print(PyQt5.QtWidgets.QStyleFactory.keys())
app.setStyle('Fusion')
sys.exit(app.exec_())