Skip to content

Commit

Permalink
Adjust QMessageBox type hinting
Browse files Browse the repository at this point in the history
  • Loading branch information
Liquid369 committed Oct 26, 2024
1 parent 7f6eb1c commit 591be31
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def add_defaultKeys_to_dict(dictObj: Dict[str, Any], defaultObj: Dict[str, Any])
dictObj[key] = defaultObj[key]


QT_MESSAGE_TYPE: Dict[str, Type[QMessageBox.Icon]] = {
QT_MESSAGE_TYPE: Dict[str, QMessageBox.Icon] = {
"info": QMessageBox.Information,
"warn": QMessageBox.Warning,
"crit": QMessageBox.Critical,
Expand Down Expand Up @@ -258,7 +258,8 @@ def readCacheSettings() -> Dict[str, Any]:


def redirect_print(what: str) -> None:
with redirect_stdout(WriteStream(wqueue)):
wrapped_stream = WrapperWriteStream(WriteStream(wqueue))
with redirect_stdout(wrapped_stream):
print(what)


Expand Down Expand Up @@ -316,6 +317,17 @@ def flush(self) -> None:
pass


class WrapperWriteStream:
def __init__(self, write_stream: WriteStream):
self.write_stream = write_stream

def write(self, message: str) -> None:
self.write_stream.write(message)

def flush(self) -> None:
self.write_stream.flush()


# QObject (to be run in QThread) that blocks until data is available
# and then emits a QtSignal to the main thread.
class WriteStreamReceiver(QObject):
Expand Down

0 comments on commit 591be31

Please sign in to comment.