python - PyQt: Console-like interface as a QTextEdit subclass -


i'm novice attempting write z-machine interpreter -- specialized virtual machine text adventures zork -- in python, using pyqt4. decided subclass qtextedit program's main interface, i'm having trouble turning widget i'm looking for. have able append text it, accept user input on same line last appended character, append more text, , user must never allowed edit of text appended program or entered user. put way, have periodically make text in widget read except new text user typing @ end of it. here's code i've tried recently:

class zscreen(qtextedit):     def __init__(self,  parent=none):         super(qtextedit, self).__init__(parent)         self.setundoredoenabled(false)         self.setacceptrichtext(false)         self.readonlybefore = self.textcursor().position     def changeevent(self, e):         if self.textcursor().position < self.readonlybefore:             self.setreadonly(true)         else:             self.setreadonly(false)         super(qtextedit, self).changeevent(e)     def printto(self, text):         self.append(text)         self.movecursor(qtextcursor.end)         self.readonlybefore = self.textcursor().position 

could have 2 text windows: 1 read-only text written, , 1 user can type new text? when press enter text interpreted, , if program can use it, text gets appended read-only text widget.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -