-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode_runner.py
43 lines (38 loc) · 1.26 KB
/
code_runner.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
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QTextEdit, QLineEdit, QApplication, QDialog, QPushButton
from communication import AsynRecord, Controller
from PyQt5.QtCore import pyqtSignal
from base import Base
class CodeRunner(QWidget, Base):
def __init__(self, parent=None):
super().__init__(parent)
#self.connection = AsynRecord("XF:21IDD-CT{MC:PRV}Asyn")
self.setLayout(QVBoxLayout())
#self.messageBox = QTextEdit()
#self.messageBox.setReadOnly(True)
#self.layout().addWidget(self.messageBox)
self.input = QTextEdit()
#self.input.returnPressed.connect(self.submit)
self.submitButton = QPushButton("Run code")
self.submitButton.clicked.connect(self.submit)
self.layout().addWidget(self.input)
self.layout().addWidget(self.submitButton)
def submit(self):
cmd = self.input.toPlainText()
#print(cmd)
#print(cmd.split('\n'))
cmd = cmd.split('\n')
#print(cmd)
try:
for line in cmd:
r = self.controller.connection.send_recv(line+"\r")
except TimeoutError:
self.emit_timeout_error()
return
#self.messageBox.append(r)
if __name__ == "__main__":
app = QApplication([])
terminal = CodeRunner()
terminal.controller.set_pmac_socket("192.168.11.21", 1025)
#terminal.controller.set_pmac_socket(None, None)
terminal.show()
app.exec()