mirror of https://gitlab.com/pamhyr/pamhyr2
SolverLog: Add colors.
parent
527a16f818
commit
21c59dbcac
|
|
@ -92,7 +92,7 @@ class SolverLogWindow(ASubMainWindow, ListedSubWindow):
|
||||||
self._alarm.start(500)
|
self._alarm.start(500)
|
||||||
self._output = Queue()
|
self._output = Queue()
|
||||||
|
|
||||||
self._log(f" *** Run solver {self._solver.name}")
|
self._log(f" *** Run solver {self._solver.name}", color="blue")
|
||||||
self._solver.run(self._process, self._output)
|
self._solver.run(self._process, self._output)
|
||||||
|
|
||||||
def setup_action(self):
|
def setup_action(self):
|
||||||
|
|
@ -110,13 +110,21 @@ class SolverLogWindow(ASubMainWindow, ListedSubWindow):
|
||||||
|
|
||||||
self._alarm.timeout.connect(self.update)
|
self._alarm.timeout.connect(self.update)
|
||||||
|
|
||||||
def _log(self, msg):
|
def _log(self, msg, color=None):
|
||||||
if type(msg) == str:
|
if type(msg) == str:
|
||||||
msg = msg.rsplit('\n')[0]
|
msg = msg.rsplit('\n')[0]
|
||||||
|
|
||||||
|
if color is not None:
|
||||||
|
msg = f"<font color=\"{color}\">" + msg + "</font>"
|
||||||
|
|
||||||
self.find(QTextEdit, "textEdit").append(msg)
|
self.find(QTextEdit, "textEdit").append(msg)
|
||||||
|
|
||||||
elif type(msg) == int:
|
elif type(msg) == int:
|
||||||
|
color = "blue" if msg == 0 else "red"
|
||||||
self.find(QTextEdit, "textEdit")\
|
self.find(QTextEdit, "textEdit")\
|
||||||
.append(f" *** Solver finished with code {msg}")
|
.append(f"<font color=\"{color}\">" +
|
||||||
|
f"*** Solver finished with code {msg}" +
|
||||||
|
"</font>")
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
while self._output.qsize() != 0:
|
while self._output.qsize() != 0:
|
||||||
|
|
@ -124,7 +132,7 @@ class SolverLogWindow(ASubMainWindow, ListedSubWindow):
|
||||||
self._log(s)
|
self._log(s)
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
self._log(" *** Start")
|
self._log(" *** Start", color="blue")
|
||||||
|
|
||||||
self._solver.start()
|
self._solver.start()
|
||||||
|
|
||||||
|
|
@ -133,7 +141,7 @@ class SolverLogWindow(ASubMainWindow, ListedSubWindow):
|
||||||
self.find(QAction, "action_stop").setEnabled(True)
|
self.find(QAction, "action_stop").setEnabled(True)
|
||||||
|
|
||||||
def pause(self):
|
def pause(self):
|
||||||
self._log(" *** Pause")
|
self._log(" *** Pause", color="blue")
|
||||||
|
|
||||||
self._solver.pause()
|
self._solver.pause()
|
||||||
|
|
||||||
|
|
@ -142,7 +150,7 @@ class SolverLogWindow(ASubMainWindow, ListedSubWindow):
|
||||||
self.find(QAction, "action_stop").setEnabled(True)
|
self.find(QAction, "action_stop").setEnabled(True)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self._log(" *** Stop")
|
self._log(" *** Stop", color="blue")
|
||||||
|
|
||||||
self._solver.kill()
|
self._solver.kill()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue