def eventFilter(self, source, event):
# Console Input
if source is self.ui.console_input:
if event.type() == QEvent.KeyPress:
if event.key() in (Qt.Key_Enter, Qt.Key_Return):
command = self.ui.console_input.text()
if command != "":
readline.add_history(
command
)
self.length = readline.get_current_history_length()
self.index = -1
if event.key() == Qt.Key_Up:
if self.index < self.length:
self.index += 1
command = readline.get_history_item(
self.length - self.index
)
self.ui.console_input.setText(
command
)
if event.key() == Qt.Key_Down:
if self.index > 0:
self.index -= 1
command = readline.get_history_item(
self.length - self.index
)
self.ui.console_input.setText(
command
)
return False
return False
评论列表
文章目录