mirror of https://gitlab.com/pamhyr/pamhyr2
Debug: Switch to multiline debug command.
parent
609e9d39db
commit
17b11b34a7
|
|
@ -18,7 +18,7 @@ from PyQt5.QtWidgets import (
|
|||
QTimeEdit, QSpinBox, QTextEdit,
|
||||
QRadioButton, QComboBox, QFileDialog,
|
||||
QMessageBox, QTableView, QAction,
|
||||
QDateTimeEdit, QWidget,
|
||||
QDateTimeEdit, QWidget, QPlainTextEdit,
|
||||
)
|
||||
from PyQt5.QtCore import (
|
||||
QTime, QDateTime,
|
||||
|
|
@ -179,6 +179,29 @@ class ASubWindowFeatures(object):
|
|||
"""
|
||||
return self.find(QTextEdit, name).toHtml()
|
||||
|
||||
def set_plaintext_edit_text(self, name:str, text:str):
|
||||
"""Set text of text edit component
|
||||
|
||||
Args:
|
||||
text_edit: The text edit component name
|
||||
text: The text
|
||||
|
||||
Returns:
|
||||
Nothing
|
||||
"""
|
||||
self.find(QPlainTextEdit, name).setPlainText(text)
|
||||
|
||||
def get_plaintext_edit_text(self, name:str):
|
||||
"""Get text of text edit component
|
||||
|
||||
Args:
|
||||
text_edit: The text edit component name
|
||||
|
||||
Returns:
|
||||
Text
|
||||
"""
|
||||
return self.find(QPlainTextEdit, name).toPlainText()
|
||||
|
||||
def set_check_box(self, name:str, checked:bool):
|
||||
"""Set status of checkbox component
|
||||
|
||||
|
|
|
|||
|
|
@ -51,8 +51,8 @@ class ReplWindow(ASubMainWindow, ListedSubWindow):
|
|||
self.setup_connections()
|
||||
|
||||
def setup_connections(self):
|
||||
self._hup_sc = QShortcut(QKeySequence("Up"), self)
|
||||
self._hdown_sc = QShortcut(QKeySequence("Down"), self)
|
||||
self._hup_sc = QShortcut(QKeySequence("ctrl+Up"), self)
|
||||
self._hdown_sc = QShortcut(QKeySequence("ctrl+Down"), self)
|
||||
self._hup_sc.activated.connect(self.history_up)
|
||||
self._hdown_sc.activated.connect(self.history_down)
|
||||
|
||||
|
|
@ -61,21 +61,25 @@ class ReplWindow(ASubMainWindow, ListedSubWindow):
|
|||
def history_up(self):
|
||||
if self._history_ind < len(self._history):
|
||||
self._history_ind += 1
|
||||
self.set_line_edit_text("lineEdit", self._history[-self._history_ind])
|
||||
self.set_plaintext_edit_text("plainTextEdit", self._history[-self._history_ind])
|
||||
|
||||
def history_down(self):
|
||||
if self._history_ind > 0:
|
||||
self._history_ind -= 1
|
||||
self.set_line_edit_text("lineEdit", self._history[-self._history_ind])
|
||||
self.set_plaintext_edit_text("plainTextEdit", self._history[-self._history_ind])
|
||||
else:
|
||||
self.set_plaintext_edit_text("plainTextEdit", "")
|
||||
|
||||
def eval_python(self):
|
||||
code = self.get_line_edit_text("lineEdit")
|
||||
code = self.get_plaintext_edit_text("plainTextEdit")
|
||||
self._history.append(code)
|
||||
self.set_line_edit_text("lineEdit", "")
|
||||
self.set_plaintext_edit_text("plainTextEdit", "")
|
||||
self._history_ind = 0
|
||||
|
||||
rich_code = "self.__debug_exec_result__ = " + code
|
||||
logger.debug(f"{code}")
|
||||
rich_code = code.strip().split("\n")
|
||||
rich_code[-1] = "self.__debug_exec_result__ = " + rich_code[-1]
|
||||
rich_code = "\n".join(rich_code)
|
||||
logger.debug(f"User debug command : {rich_code}")
|
||||
try:
|
||||
value = exec(rich_code)
|
||||
value = self.__debug_exec_result__
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit"/>
|
||||
<widget class="QPlainTextEdit" name="plainTextEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
|
|
|
|||
Loading…
Reference in New Issue