### Navigation

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

# Module: `qt.console.mainwindow`

The Qt MainWindow for the QtConsole

This is a tabbed pseudo-terminal of IPython sessions, with a menu bar for common actions.

Authors:

- Evan Patterson
- Min RK
- Erik Tollerud
- Fernando Perez
- Bussonnier Matthias
- Thomas Kluyver
- Paul Ivanov

## 1 Class

class `IPython.qt.console.mainwindow.``MainWindow`(app, confirm_exit=True, new_frontend_factory=None, slave_frontend_factory=None)

  Bases: `PyQt4.QtGui.QMainWindow`

  `__init__`(app, confirm_exit=True, new_frontend_factory=None, slave_frontend_factory=None)

    Create a tabbed MainWindow for managing IPython FrontendWidgets

    Parameters: | app : reference to QApplication parent confirm_exit : bool, optional Whether we should prompt on close of tabs new_frontend_factory : callable A callable that returns a new IPythonWidget instance, attached to its own running kernel. slave_frontend_factory : callable A callable that takes an existing IPythonWidget, and returns a new IPythonWidget instance, attached to the same kernel.

  `add_menu_action`(menu, action, defer_shortcut=False)

    Add action to menu as well as self

    So that when the menu bar is invisible, its actions are still available.

    If defer_shortcut is True, set the shortcut context to widget-only, where it will avoid conflict with shortcuts already bound to the widgets themselves.

  `add_tab_with_frontend`(frontend, name=None)

    insert a tab with a given frontend in the tab bar, and give it a name

  `closeEvent`(event)

    Forward the close event to every tabs contained by the windows

  `close_tab`(current_tab)

    Called when you need to try to close a tab.

    It takes the number of the tab to be closed as argument, or a reference to the widget inside this tab

  `create_tab_with_current_kernel`()

    create a new frontend attached to the same kernel as the current tab

  `create_tab_with_new_frontend`()

    create a new frontend and attach it to a new tab

  `find_master_tab`(tab, as_list=False)

    Try to return the frontend that owns the kernel attached to the given widget/tab.

    > Only finds frontend owned by the current application. Selection based on port of the kernel might be inaccurate if several kernel on different ip use same port number.

    > This function does the conversion tabNumber/widget if needed. Might return None if no master widget (non local kernel) Will crash IPython if more than 1 masterWidget

    > When asList set to True, always return a list of widget(s) owning the kernel. The list might be empty or containing several Widget.

  `find_slave_widgets`(tab)

    return all the frontends that do not own the kernel attached to the given widget/tab.

    Only find frontends owned by the current application. Selection based on connection file of the kernel.

    This function does the conversion tabNumber/widget if needed.

  `next_kernel_id`

    constantly increasing counter for kernel IDs

  `populate_all_magic_menu`(display_data=None)

    Clean “All Magics...” menu and repopulate it with display_data

    Parameters: | display_data : dict, dict of display_data for the magics dict of a MagicsManager. Expects json data, as the result of %lsmagic

  `update_all_magic_menu`()

    Update the list of magics in the “All Magics...” Menu

    Request the kernel with the list of available magics and populate the menu with the list received back

  `update_tab_bar_visibility`()

    update visibility of the tabBar depending of the number of tab

    0 or 1 tab, tabBar hidden 2+ tabs, tabBar visible

    send a self.close if number of tab ==0

    need to be called explicitly, or be connected to tabInserted/tabRemoved

## 1 Function

`IPython.qt.console.mainwindow.``background`(f)

  call a function in a simple thread, to prevent blocking

### Navigation

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