Skip to content

Instantly share code, notes, and snippets.

@eyllanesc
Created September 5, 2017 14:42
Show Gist options
  • Save eyllanesc/787417ef62fc0bcd05bde10d02724e4e to your computer and use it in GitHub Desktop.
Save eyllanesc/787417ef62fc0bcd05bde10d02724e4e to your computer and use it in GitHub Desktop.
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()
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