def apply_color_scheme(self, color_scheme): """ Apply a pygments color scheme to the console. As there is not a 1 to 1 mapping between color scheme formats and console formats, we decided to make the following mapping (it usually looks good for most of the available pygments styles): - stdout_color = normal color - stderr_color = red (lighter if background is dark) - stdin_color = numbers color - app_msg_color = string color - bacgorund_color = background :param color_scheme: pyqode.core.api.ColorScheme to apply """ self.stdout_color = color_scheme.formats['normal'].foreground().color() self.stdin_color = color_scheme.formats['number'].foreground().color() self.app_msg_color = color_scheme.formats['string'].foreground().color( ) self.background_color = color_scheme.background if self.background_color.lightness() < 128: self.stderr_color = QColor('#FF8080') else: self.stderr_color = QColor('red')
def __init__(self, parent=None): super(InteractiveConsole, self).__init__(parent) self._stdout_col = QColor("#404040") self._app_msg_col = QColor("#4040FF") self._stdin_col = QColor("#22AA22") self._stderr_col = QColor("#FF0000") self._process = None self._args = None self._usr_buffer = "" self._clear_on_start = True self.process = QProcess() self._merge_outputs = False self.process.finished.connect(self._on_process_finished) self.process.error.connect(self._write_error) self.process.readyReadStandardError.connect(self._on_stderr) self.process.readyReadStandardOutput.connect(self._on_stdout) self._running = False self._writer = self.write self._user_stop = False font = "monospace" if sys.platform == "win32": font = "Consolas" elif sys.platform == "darwin": font = 'Monaco' self._font_family = font self.setFont(QFont(font, 10)) self.setReadOnly(True)
def paintEvent(self, e): qp = QPainter() qp.begin(self) qp.setPen(QColor(0, 0, 0)) qp.drawRect(QRect(0, 0, self.width() - 1, self.height() - 1)) qp.setPen(QPen(QColor(255, 255, 255), 1, Qt.DashLine)) qp.drawRect(QRect(0, 0, self.width() - 1, self.height() - 1)) qp.end()
def __init__(self): QFrame.__init__(self) self.setFrameShape(QFrame.HLine) self.setContentsMargins(0, 0, 0, 0) pal = self.palette() pal.setColor(QPalette.Foreground, QColor(150, 150, 150)) self.setPalette(pal)
def __init__(self, parent=None): super(InteractiveConsole, self).__init__(parent) self.panels = PanelsManager(self) self.decorations = TextDecorationsManager(self) from pyqode.core.panels import SearchAndReplacePanel self.panels.append(SearchAndReplacePanel(), SearchAndReplacePanel.Position.TOP) self._stdout_col = QColor("#404040") self._app_msg_col = QColor("#4040FF") self._stdin_col = QColor("#22AA22") self._stderr_col = QColor("#FF0000") self._write_app_messages = True self._process_name = '' self.process = None self._args = None self._usr_buffer = "" self._clear_on_start = True self._merge_outputs = False self._running = False self._writer = self.write self._user_stop = False font = "monospace" if sys.platform == "win32": font = "Consolas" elif sys.platform == "darwin": font = 'Monaco' self._font_family = font self.setFont(QFont(font, 10)) self.setReadOnly(True) self._mask_user_input = False action = QAction('Copy', self) action.setShortcut(QKeySequence.Copy) action.triggered.connect(self.copy) self.add_action(action) action = QAction('Paste', self) action.setShortcut(QKeySequence.Paste) action.triggered.connect(self.paste) self.add_action(action)