### Navigation

- index
- modules |
- modules |
- next |
- previous |
- home|
- search|
- documentation »
- The IPython API »

# Module: `qt.console.console_widget`

An abstract base class for console-type widgets.

## 1 Class

class `IPython.qt.console.console_widget.``ConsoleWidget`(parent=None, **kw)

  Bases: `IPython.qt.util.NewBase`

  An abstract base class for console-type widgets. This class has functionality for:

  > - Maintaining a prompt and editing region
  > - Providing the traditional Unix-style console keyboard shortcuts
  > - Performing tab completion
  > - Paging text
  > - Handling ANSI escape codes

  ConsoleWidget also provides a number of utility methods that will be convenient to implementors of a console-style widget.

  `__init__`(parent=None, **kw)

    Create a ConsoleWidget.

    Parameters :

    parent : QWidget, optional [default None]

    > The parent for this widget.

  `can_copy`()

    Returns whether text can be copied to the clipboard.

  `can_cut`()

    Returns whether text can be cut to the clipboard.

  `can_paste`()

    Returns whether text can be pasted from the clipboard.

  `change_font_size`(delta)

    Change the font size by the specified amount (in points).

  `clear`(keep_input=True)

    Clear the console.

    Parameters :

    keep_input : bool, optional (default True)

    > If set, restores the old input buffer if a new prompt is written.

  `copy`()

    Copy the currently selected text to the clipboard.

  `copy_anchor`(anchor)

    Copy anchor text to the clipboard

  `cut`()

    Copy the currently selected text to the clipboard and delete it if it’s inside the input buffer.

  `eventFilter`(obj, event)

    Reimplemented to ensure a console-like behavior in the underlying text widgets.

  `execute`(source=None, hidden=False, interactive=False)

    Executes source or the input buffer, possibly prompting for more input.

    Parameters :

    source : str, optional

    > The source to execute. If not specified, the input buffer will be used. If specified and ‘hidden’ is False, the input buffer will be replaced with the source before execution.

    hidden : bool, optional (default False)

    > If set, no output will be shown and the prompt will not be modified. In other words, it will be completely invisible to the user that an execution has occurred.

    interactive : bool, optional (default False)

    > Whether the console is to treat the source as having been manually entered by the user. The effect of this parameter depends on the subclass implementation.

    Returns : | A boolean indicating whether the source was executed. :

    Raises :

    RuntimeError :

    > If incomplete input is given and ‘hidden’ is True. In this case, it is not possible to prompt for more input.

  `export_html`()

    Shows a dialog to export HTML/XML in various formats.

  `font`

    The base font being used by the ConsoleWidget.

  `input_buffer`

    The text that the user has entered entered at the current prompt.

    If the console is currently executing, the text that is executing will always be returned.

  `open_anchor`(anchor)

    Open selected anchor in the default webbrowser

  `paste`(mode=0)

    Paste the contents of the clipboard into the input region.

    Parameters :

    mode : QClipboard::Mode, optional [default QClipboard::Clipboard]

    > Controls which part of the system clipboard is used. This can be used to access the selection clipboard in X11 and the Find buffer in Mac OS. By default, the regular clipboard is used.

  `print_`(printer=None)

    Print the contents of the ConsoleWidget to the specified QPrinter.

  `prompt_to_top`()

    Moves the prompt to the top of the viewport.

  `redo`()

    Redo the last operation. If there is no operation to redo, nothing happens.

  `reset_font`()

    Sets the font to the default fixed-width font for this platform.

  `select_all`()

    Selects all the text in the buffer.

  `sizeHint`()

    Reimplemented to suggest a size that is 80 characters wide and 25 lines high.

  `tab_width`

    The width (in terms of space characters) for tab characters.

  `undo`()

    Undo the last operation. If there is no operation to undo, nothing happens.

## 2 Functions

`IPython.qt.console.console_widget.``commonprefix`(items)

  Get common prefix for completions

  Return the longest common prefix of a list of strings, but with special treatment of escape characters that might precede commands in IPython, such as %magic functions. Used in tab completion.

  For a more general function, see os.path.commonprefix

`IPython.qt.console.console_widget.``is_letter_or_number`(char)

  Returns whether the specified unicode character is a letter or a number.

### Navigation

- index
- modules |
- modules |
- next |
- previous |
- home|
- search|
- documentation »
- The IPython API »