|
10 | 10 | from qtpy import QtCore |
11 | 11 | from qtpy.QtCore import QObject |
12 | 12 | from qtpy.QtCore import Qt |
13 | | -from qtpy.QtCore import QtWarningMsg |
| 13 | +# from qtpy.QtCore import QtWarningMsg |
14 | 14 | from qtpy.QtCore import QUrl |
15 | 15 | from qtpy.QtGui import QCursor |
16 | 16 | from qtpy.QtGui import QDesktopServices |
@@ -105,24 +105,25 @@ def __call__(cls, *args, **kwargs): |
105 | 105 | def handle_adjust_errors(widget, type, context, msg: str): |
106 | 106 | """Qt message handler that attempts to react to errors when setting the window size |
107 | 107 | and resizes the main window""" |
108 | | - head = msg.split(": ")[0] |
109 | | - if type == QtWarningMsg and head == "QWindowsWindow::setGeometry": |
110 | | - logger.warning( |
111 | | - f"Qt resize error : {msg}\nhas been handled by attempting to resize the window" |
112 | | - ) |
113 | | - try: |
114 | | - if widget.parent() is not None: |
115 | | - state = int(widget.parent().parent().windowState()) |
116 | | - if state == 0: # normal state |
117 | | - widget.parent().parent().adjustSize() |
118 | | - logger.debug("Non-max. size adjust attempt") |
119 | | - logger.debug(f"{widget.parent().parent()}") |
120 | | - elif state == 2: # maximized state |
121 | | - widget.parent().parent().showNormal() |
122 | | - widget.parent().parent().showMaximized() |
123 | | - logger.debug("Maximized size adjust attempt") |
124 | | - except RuntimeError: |
125 | | - pass |
| 108 | + pass |
| 109 | + # head = msg.split(": ")[0] |
| 110 | + # if type == QtWarningMsg and head == "QWindowsWindow::setGeometry": |
| 111 | + # logger.warning( |
| 112 | + # f"Qt resize error : {msg}\nhas been handled by attempting to resize the window" |
| 113 | + # ) |
| 114 | + # try: |
| 115 | + # if widget.parent() is not None: |
| 116 | + # state = int(widget.parent().parent().windowState()) |
| 117 | + # if state == 0: # normal state |
| 118 | + # widget.parent().parent().adjustSize() |
| 119 | + # logger.debug("Non-max. size adjust attempt") |
| 120 | + # logger.debug(f"{widget.parent().parent()}") |
| 121 | + # elif state == 2: # maximized state |
| 122 | + # widget.parent().parent().showNormal() |
| 123 | + # widget.parent().parent().showMaximized() |
| 124 | + # logger.debug("Maximized size adjust attempt") |
| 125 | + # except RuntimeError: |
| 126 | + # pass |
126 | 127 |
|
127 | 128 |
|
128 | 129 | def handle_adjust_errors_wrapper(widget): |
@@ -223,31 +224,31 @@ def __init__(self, parent=None): |
223 | 224 |
|
224 | 225 | # def receive_log(self, text): |
225 | 226 | # self.print_and_log(text) |
226 | | - # def write(self, message): |
227 | | - # """ |
228 | | - # Write message to log in a thread-safe manner |
229 | | - # Args: |
230 | | - # message: string to be printed |
231 | | - # """ |
232 | | - # self.lock.acquire() |
233 | | - # try: |
234 | | - # if not hasattr(self, "flag"): |
235 | | - # self.flag = False |
236 | | - # message = message.replace("\r", "").rstrip() |
237 | | - # if message: |
238 | | - # method = "replace_last_line" if self.flag else "append" |
239 | | - # QtCore.QMetaObject.invokeMethod( |
240 | | - # self, |
241 | | - # method, |
242 | | - # QtCore.Qt.QueuedConnection, |
243 | | - # QtCore.Q_ARG(str, message), |
244 | | - # ) |
245 | | - # self.flag = True |
246 | | - # else: |
247 | | - # self.flag = False |
248 | | - # |
249 | | - # finally: |
250 | | - # self.lock.release() |
| 227 | + def write(self, message): |
| 228 | + """ |
| 229 | + Write message to log in a thread-safe manner |
| 230 | + Args: |
| 231 | + message: string to be printed |
| 232 | + """ |
| 233 | + self.lock.acquire() |
| 234 | + try: |
| 235 | + if not hasattr(self, "flag"): |
| 236 | + self.flag = False |
| 237 | + message = message.replace("\r", "").rstrip() |
| 238 | + if message: |
| 239 | + method = "replace_last_line" if self.flag else "append" |
| 240 | + QtCore.QMetaObject.invokeMethod( |
| 241 | + self, |
| 242 | + method, |
| 243 | + QtCore.Qt.QueuedConnection, |
| 244 | + QtCore.Q_ARG(str, message), |
| 245 | + ) |
| 246 | + self.flag = True |
| 247 | + else: |
| 248 | + self.flag = False |
| 249 | + |
| 250 | + finally: |
| 251 | + self.lock.release() |
251 | 252 |
|
252 | 253 | @QtCore.Slot(str) |
253 | 254 | def replace_last_line(self, text): |
|
0 commit comments