-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparsergui.py
53 lines (45 loc) · 1.67 KB
/
parsergui.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
import sys
from PyQt5.QtWidgets import QApplication ,QTextEdit ,QWidget ,QPushButton ,QVBoxLayout ,QHBoxLayout,QMessageBox
from PARSER import *
import os.path
class Notepad(QWidget):
def __init__(self):
super(Notepad, self).__init__()
self.text = QTextEdit(self)
self.save_button = QPushButton('SAVE')
self.clear_button = QPushButton('CLEAR')
self.generate_button = QPushButton('GENERATE')
self.exit_button = QPushButton('EXIT')
self.init_ui()
def init_ui(self):
layout = QVBoxLayout()
layout.addWidget(self.text)
layout.addWidget(self.save_button)
self.save_button.clicked.connect(self.save_text)
layout.addWidget(self.clear_button)
self.clear_button.clicked.connect(self.clear_text)
layout.addWidget(self.generate_button)
self.generate_button.clicked.connect(self.generate)
layout.addWidget(self.exit_button)
self.exit_button.clicked.connect(self.close)
self.setLayout(layout)
self.setWindowTitle('Parser Gui')
self.show()
def clear_text(self):
self.text.clear()
def save_text(self):
with open('input.txt','w') as f:
my_text = self.text.toPlainText()
f.write(my_text)
def generate(self):
if os.path.isfile('input.txt'):
try:
programe()
except Error as error:
QMessageBox.about(self, 'Error', error.message)
else:
QMessageBox.about(self, 'Error', "No Code entered yet!!")
if __name__ == '__main__':
app = QApplication(sys.argv)
writer = Notepad()
sys.exit(app.exec_())