-
Notifications
You must be signed in to change notification settings - Fork 0
/
qt.py
89 lines (72 loc) · 2.3 KB
/
qt.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
#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
Created on Nov 29, 2019
Desc: Webp convertor QT
@author: Mashiro @ https://2heng.xin
"""
import sys
import time
from PyQt5.QtWidgets import QMainWindow, QWidget, QApplication, QPushButton, QMessageBox, QDesktopWidget, QGridLayout
from PyQt5.QtCore import QCoreApplication
from PyQt5.QtGui import QIcon
from manifest import main as manifest
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.statusBar().showMessage('Ready')
self.BtnWid = QWidget(self)
self.setCentralWidget(self.BtnWid)
grid = QGridLayout()
self.BtnWid.setLayout(grid)
names = ['Generate manifest.json',
'Pull from GitHub',
'Push to GitHub',
'Release on GitHub',
'Push manifest.json to WordPress',
'About and Turtor']
actions = [self.Action_1,
self.Action_0,
self.Action_0,
self.Action_0,
self.Action_0]
positions = [(i, j) for i in range(6) for j in range(1)]
for position, name, action in zip(positions, names, actions):
if name == '':
continue
button = QPushButton(name)
button.clicked.connect(action)
grid.addWidget(button, *position)
# self.resize(500, 500)
self.center()
self.setWindowTitle('Manifest Generator')
self.setWindowIcon(QIcon('icon.png'))
self.show()
def Action_0(self):
sender = self.sender()
self.statusBar().showMessage('"' + sender.text() + '" was pressed')
#Generate manifest.json
def Action_1(self):
# self.statusBar().showMessage('Processing...')
# time.sleep(1)
manifest()
self.statusBar().showMessage('`manifest.json` saved.')
def center(self):
qr = self.frameGeometry()
cp = QDesktopWidget().availableGeometry().center()
qr.moveCenter(cp)
self.move(qr.topLeft())
def closeEvent(self, event):
reply = QMessageBox.question(self, 'Message',
"Are you sure to quit?", QMessageBox.Yes |
QMessageBox.No, QMessageBox.No)
if reply == QMessageBox.Yes:
event.accept()
else:
event.ignore()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = MainWindow()
sys.exit(app.exec_())