Skip to content

Commit

Permalink
Small text mode adjustemnts
Browse files Browse the repository at this point in the history
  • Loading branch information
harbaum committed May 2, 2016
1 parent 5f96c70 commit 36ec990
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions board/fischertechnik/TXT/rootfs/opt/ftc/ftc_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
app = None
app_executable = ""

# A fullscreen message dialog. Currently only used to show the
# "shutting down" message
class MessageDialog(QDialog):
def __init__(self,str):
QDialog.__init__(self)
Expand Down Expand Up @@ -181,6 +183,8 @@ def animate(self):
self.repaint()

def close(self):
self.etimer.stop()
self.atimer.stop()
super(BusyAnimation, self).close()
super(BusyAnimation, self).deleteLater()

Expand All @@ -202,17 +206,12 @@ def paintEvent(self, event):

painter.end()

class OutputDialog(TxtDialog):
class TextmodeDialog(TxtDialog):
def __init__(self,title,parent):
TxtDialog.__init__(self, title, parent)

self.txt = QTextEdit()
self.txt.setReadOnly(True)

font = QFont()
font.setPointSize(16)
self.txt.setFont(font)

self.setCentralWidget(self.txt)

self.p = None
Expand Down Expand Up @@ -244,6 +243,10 @@ def append(self, str):
self.txt.moveCursor(QTextCursor.End)
self.txt.insertPlainText(str)

def close(self):
self.timer.stop()
TxtDialog.close(self)

class FtcGuiApplication(QApplication):
def __init__(self, args):
QApplication.__init__(self, args)
Expand Down Expand Up @@ -321,12 +324,14 @@ def on_app_running(self, pid):
if self.popup:
self.popup.close()

def launch_textmode_app(self, executable,name):
dialog = OutputDialog(name, self.w)
def launch_textmode_app(self, executable, name):
global app, app_executable
dialog = TextmodeDialog(name, self.w)

app_executable = executable
master_fd, slave_fd = pty.openpty()
p = subprocess.Popen(str(executable), stdout=slave_fd, stderr=slave_fd)
dialog.poll(p, master_fd)
app = subprocess.Popen(str(executable), stdout=slave_fd, stderr=slave_fd)
dialog.poll(app, master_fd)
dialog.exec_()
os.close(master_fd)
os.close(slave_fd)
Expand All @@ -342,7 +347,7 @@ def launch_app(self, executable, managed, name):
if managed.lower() == "text":
self.launch_textmode_app(executable, name)
return

# run the executable
app_executable = executable
app = subprocess.Popen(str(executable))
Expand Down

0 comments on commit 36ec990

Please sign in to comment.