Created
September 5, 2017 14:42
-
-
Save eyllanesc/787417ef62fc0bcd05bde10d02724e4e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from PyQt4.QtGui import * | |
from PyQt4.QtCore import * | |
def process(text): | |
# Emulate processing | |
return [c for c in text] | |
class Widget(QWidget): | |
def __init__(self, parent=None): | |
QWidget.__init__(self, parent) | |
self.setLayout(QVBoxLayout()) | |
self.le = QLineEdit(self) | |
self.te = QTextEdit(self) | |
self.layout().addWidget(self.le) | |
self.layout().addWidget(self.te) | |
self.le.returnPressed.connect(self.onReturnPressed) | |
def onReturnPressed(self): | |
# process | |
output = process(self.le.text()) | |
[self.te.append(c) for c in output] | |
def main(): | |
app = QApplication(sys.argv) | |
w = Widget() | |
w.show() | |
sys.exit(app.exec_()) | |
if __name__ == '__main__': | |
main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from PyQt5.QtWidgets import * | |
from PyQt5.QtGui import * | |
from PyQt5.QtCore import * | |
def process(text): | |
# Emulate processing | |
return [c for c in text] | |
class Widget(QWidget): | |
def __init__(self, parent=None): | |
QWidget.__init__(self, parent) | |
self.setLayout(QVBoxLayout()) | |
self.le = QLineEdit(self) | |
self.te = QTextEdit(self) | |
self.layout().addWidget(self.le) | |
self.layout().addWidget(self.te) | |
self.le.returnPressed.connect(self.onReturnPressed) | |
def onReturnPressed(self): | |
# process | |
output = process(self.le.text()) | |
[self.te.append(c) for c in output] | |
def main(): | |
app = QApplication(sys.argv) | |
w = Widget() | |
w.show() | |
sys.exit(app.exec_()) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment