Beispiel #1
0
    def __init__(self, parent=None):
        TextEditBaseWidget.__init__(self, parent)

        # We use an object name to set the right background
        # color when changing interface theme. This seems to
        # be a Qt bug.
        # Fixes issue 8072
        self.setObjectName('console')

        self.setMaximumBlockCount(300)

        # ANSI escape code handler
        self.ansi_handler = QtANSIEscapeCodeHandler()

        # Disable undo/redo (nonsense for a console widget...):
        self.setUndoRedoEnabled(False)

        self.userListActivated.connect(
            lambda user_id, text: self.completion_widget_activated.emit(text))

        background_color = MAIN_BG_COLOR
        default_foreground_color = MAIN_DEFAULT_FG_COLOR
        error_foreground_color = MAIN_ERROR_FG_COLOR
        traceback_foreground_color = MAIN_TB_FG_COLOR
        prompt_foreground_color = MAIN_PROMPT_FG_COLOR

        self.default_style = ConsoleFontStyle(
            foregroundcolor=default_foreground_color,
            backgroundcolor=background_color,
            bold=False,
            italic=False,
            underline=False)
        self.error_style = ConsoleFontStyle(
            foregroundcolor=error_foreground_color,
            backgroundcolor=background_color,
            bold=False,
            italic=False,
            underline=False)
        self.traceback_link_style = ConsoleFontStyle(
            foregroundcolor=traceback_foreground_color,
            backgroundcolor=background_color,
            bold=True,
            italic=False,
            underline=True)
        self.prompt_style = ConsoleFontStyle(
            foregroundcolor=prompt_foreground_color,
            backgroundcolor=background_color,
            bold=True,
            italic=False,
            underline=False)
        self.font_styles = (self.default_style, self.error_style,
                            self.traceback_link_style, self.prompt_style)

        self.set_color_scheme(default_foreground_color, background_color)
        self.setMouseTracking(True)
Beispiel #2
0
    def __init__(self, parent=None):
        TextEditBaseWidget.__init__(self, parent)

        # We use an object name to set the right background
        # color when changing interface theme. This seems to
        # be a Qt bug.
        # Fixes issue 8072
        self.setObjectName('console')

        self.setMaximumBlockCount(300)

        # ANSI escape code handler
        self.ansi_handler = QtANSIEscapeCodeHandler()

        # Disable undo/redo (nonsense for a console widget...):
        self.setUndoRedoEnabled(False)

        self.userListActivated.connect(
            lambda user_id, text: self.completion_widget_activated.emit(text))

        background_color = MAIN_BG_COLOR
        default_foreground_color = MAIN_DEFAULT_FG_COLOR
        error_foreground_color = MAIN_ERROR_FG_COLOR
        traceback_foreground_color = MAIN_TB_FG_COLOR
        prompt_foreground_color = MAIN_PROMPT_FG_COLOR

        self.default_style = ConsoleFontStyle(
                            foregroundcolor=default_foreground_color,
                            backgroundcolor=background_color,
                            bold=False, italic=False, underline=False)
        self.error_style = ConsoleFontStyle(
                            foregroundcolor=error_foreground_color,
                            backgroundcolor=background_color,
                            bold=False, italic=False, underline=False)
        self.traceback_link_style = ConsoleFontStyle(
                            foregroundcolor=traceback_foreground_color,
                            backgroundcolor=background_color,
                            bold=True, italic=False, underline=True)
        self.prompt_style = ConsoleFontStyle(
                            foregroundcolor=prompt_foreground_color,
                            backgroundcolor=background_color,
                            bold=True, italic=False, underline=False)
        self.font_styles = (self.default_style, self.error_style,
                            self.traceback_link_style, self.prompt_style)

        self.set_color_scheme(default_foreground_color, background_color)
        self.setMouseTracking(True)