Skip to content

Commit aa3fb5f

Browse files
committed
Add QApplication.processEvents()
1 parent 01a0e30 commit aa3fb5f

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Uploader_GUI/RTK_Firmware_Uploader_GUI.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
from typing import Iterator, Tuple
3737

38-
from PyQt5.QtCore import QSettings, QProcess, QTimer, Qt, QIODevice, pyqtSlot
38+
from PyQt5.QtCore import QSettings, QProcess, QTimer, Qt, QIODevice, pyqtSlot, QObject
3939
from PyQt5.QtWidgets import QWidget, QLabel, QComboBox, QGridLayout, \
4040
QPushButton, QApplication, QLineEdit, QFileDialog, QPlainTextEdit, \
4141
QAction, QActionGroup, QMenu, QMenuBar, QMainWindow, QMessageBox
@@ -71,7 +71,7 @@ def resource_path(relative_path):
7171
base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
7272
return os.path.join(base_path, relative_path)
7373

74-
class messageRedirect:
74+
class messageRedirect(QObject):
7575
"""Wrap a class around a QPlainTextEdit so we can redirect stdout and stderr to it"""
7676

7777
def __init__(self, edit, out=None) -> None:
@@ -89,6 +89,7 @@ def write(self, msg) -> None:
8989
self.edit.repaint()
9090
if self.out: # Echo to out (stdout) too if desired
9191
self.out.write(msg)
92+
QApplication.processEvents()
9293

9394
def flush(self) -> None:
9495
None
@@ -189,10 +190,11 @@ def __init__(self, parent: QWidget = None) -> None:
189190

190191
def writeMessage(self, msg) -> None:
191192
self.messageBox.moveCursor(QTextCursor.End)
192-
self.messageBox.ensureCursorVisible()
193+
#self.messageBox.ensureCursorVisible()
193194
self.messageBox.appendPlainText(msg)
194195
self.messageBox.ensureCursorVisible()
195196
self.messageBox.repaint()
197+
QApplication.processEvents()
196198

197199
def _load_settings(self) -> None:
198200
"""Load settings on startup."""
@@ -368,6 +370,8 @@ def on_upload_btn_pressed(self) -> None:
368370
except:
369371
pass
370372

373+
self.messageBox.ensureCursorVisible()
374+
self.messageBox.repaint()
371375

372376
if __name__ == '__main__':
373377
from sys import exit as sysExit
@@ -376,7 +380,7 @@ def on_upload_btn_pressed(self) -> None:
376380
app.setApplicationName('SparkFun RTK Firmware Uploader ' + guiVersion)
377381
app.setWindowIcon(QIcon(resource_path("RTK.png")))
378382
w = MainWidget()
379-
if 1: # Change to 0 to have the messages echoed on stdout
383+
if 0: # Change to 0 to have the messages echoed on stdout
380384
sys.stdout = messageRedirect(w.messageBox) # Divert stdout to messageBox
381385
sys.stderr = messageRedirect(w.messageBox) # Divert stderr to messageBox
382386
else:
1.28 KB
Binary file not shown.

0 commit comments

Comments
 (0)