-
Notifications
You must be signed in to change notification settings - Fork 2
/
generator.py
159 lines (150 loc) · 8.95 KB
/
generator.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
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'generator.ui'
#
# Created by: PyQt5 UI code generator 5.15.1
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_CodeGenerator(object):
def setupUi(self, CodeGenerator):
CodeGenerator.setObjectName("CodeGenerator")
CodeGenerator.resize(800, 333)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/icons/icons/icon.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
CodeGenerator.setWindowIcon(icon)
self.centralwidget = QtWidgets.QWidget(CodeGenerator)
self.centralwidget.setObjectName("centralwidget")
self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setObjectName("verticalLayout")
self.textEdit = QtWidgets.QTextEdit(self.centralwidget)
self.textEdit.setStyleSheet("border-bottom: 2px;\n"
"border-style: solid;\n"
"border-bottom-color: rgb(255, 85, 0);")
self.textEdit.setLineWidth(1)
self.textEdit.setTextInteractionFlags(QtCore.Qt.TextSelectableByKeyboard|QtCore.Qt.TextSelectableByMouse)
self.textEdit.setObjectName("textEdit")
self.verticalLayout.addWidget(self.textEdit)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setContentsMargins(-1, 0, -1, -1)
self.horizontalLayout.setObjectName("horizontalLayout")
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
self.CopyPushButton = QtWidgets.QPushButton(self.centralwidget)
self.CopyPushButton.setStyleSheet("QPushButton#CopyPushButton {\n"
" min-width:60px;\n"
" max-width:60px;\n"
" min-height:35;\n"
" max-height:35;\n"
"\n"
" color: #495057;\n"
"\n"
" background: rgba(255,255,255,100%);\n"
" border-bottom: 2px;\n"
" border-style: solid;\n"
" border-bottom-color: rgba(0,0,0,.3);\n"
" border-top-left-radius: 0px;\n"
" border-top-right-radius: 3px;\n"
" border-bottom-right-radius: 0px;\n"
" border-bottom-left-radius: 0px;\n"
"}\n"
"\n"
"QPushButton#CopyPushButton:hover {\n"
" background: rgba(255,255,255,50%);\n"
" border-bottom-color:rgb(255, 85, 0);\n"
"}\n"
"\n"
"QPushButton#CopyPushButton:pressed {\n"
" background: rgba(255,255,255,100%);\n"
" border-bottom-color:rgb(255, 85, 0);\n"
"}\n"
"\n"
"QPushButton#CopyPushButton:disabled {\n"
" background: rgba(0,0,0,.04);\n"
" border-bottom-color: rgba(0,0,0,.15); \n"
"}")
self.CopyPushButton.setObjectName("CopyPushButton")
self.horizontalLayout.addWidget(self.CopyPushButton, 0, QtCore.Qt.AlignHCenter|QtCore.Qt.AlignVCenter)
self.ClosePushButton = QtWidgets.QPushButton(self.centralwidget)
self.ClosePushButton.setStyleSheet("QPushButton#ClosePushButton {\n"
" min-width:60px;\n"
" max-width:60px;\n"
" min-height:35;\n"
" max-height:35;\n"
"\n"
" color: #495057;\n"
"\n"
" background: rgba(255,255,255,100%);\n"
" border-bottom: 2px;\n"
" border-style: solid;\n"
" border-bottom-color: rgba(0,0,0,.3);\n"
" border-top-left-radius: 0px;\n"
" border-top-right-radius: 3px;\n"
" border-bottom-right-radius: 0px;\n"
" border-bottom-left-radius: 0px;\n"
"}\n"
"\n"
"QPushButton#ClosePushButton:hover {\n"
" background: rgba(255,255,255,50%);\n"
" border-bottom-color:rgb(255, 85, 0);\n"
"}\n"
"\n"
"QPushButton#ClosePushButton:pressed {\n"
" background: rgba(255,255,255,100%);\n"
" border-bottom-color:rgb(255, 85, 0);\n"
"}\n"
"\n"
"QPushButton#ClosePushButton:disabled {\n"
" background: rgba(0,0,0,.04);\n"
" border-bottom-color: rgba(0,0,0,.15); \n"
"}")
self.ClosePushButton.setObjectName("ClosePushButton")
self.horizontalLayout.addWidget(self.ClosePushButton, 0, QtCore.Qt.AlignHCenter|QtCore.Qt.AlignVCenter)
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem1)
self.verticalLayout.addLayout(self.horizontalLayout)
CodeGenerator.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(CodeGenerator)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21))
self.menubar.setObjectName("menubar")
CodeGenerator.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(CodeGenerator)
self.statusbar.setObjectName("statusbar")
CodeGenerator.setStatusBar(self.statusbar)
self.retranslateUi(CodeGenerator)
self.ClosePushButton.clicked.connect(CodeGenerator.close)
self.CopyPushButton.clicked.connect(self.textEdit.selectAll)
self.CopyPushButton.clicked.connect(self.textEdit.copy)
QtCore.QMetaObject.connectSlotsByName(CodeGenerator)
def retranslateUi(self, CodeGenerator):
_translate = QtCore.QCoreApplication.translate
CodeGenerator.setWindowTitle(_translate("CodeGenerator", "PyRex Code Generaotr"))
self.textEdit.setHtml(_translate("CodeGenerator", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">import re</span></p>\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;\"><br /></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">regex = r"<CHANGE_ME>pattern<CHANGE_ME>"</span></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">test_str = "<CHANGE_ME>string<CHANGE_ME>"</span></p>\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;\"><br /></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">matches = re.finditer(regex, test_str, re.MULTILINE)</span></p>\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;\"><br /></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">for matchNum, match in enumerate(matches, start=1):</span></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\"> print ("Match {matchNum} was found at {start}-{end}: {match}".format(matchNum = matchNum, start = match.start(), end = match.end(), match = match.group()))</span></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\"> for groupNum in range(0, len(match.groups())):</span></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\"> groupNum = groupNum + 1</span></p>\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;\"><br /></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\"> print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = match.start(groupNum), end = match.end(groupNum), group = match.group(groupNum)))</span></p></body></html>"))
self.CopyPushButton.setText(_translate("CodeGenerator", "Copy"))
self.ClosePushButton.setText(_translate("CodeGenerator", "Close"))
import src_rc
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
CodeGenerator = QtWidgets.QMainWindow()
ui = Ui_CodeGenerator()
ui.setupUi(CodeGenerator)
CodeGenerator.show()
sys.exit(app.exec_())