KDE 4.9 PyKDE API Reference

- KDE's Python API

# TabBar Class Reference

`from PyKDE4.plasma import *`

Inherits: QGraphicsWidget → QObject
Namespace: Plasma

## Detailed Description

TabBar plasma/widgets/tabbar.h <Plasma/Widgets/TabBar>

A tab bar widget, to be used for tabbed interfaces.

Provides a Tab bar for use in a tabbed interface where each page is a QGraphicsLayoutItem. Only one of them is displayed at a given time. It is possible to add and remove tabs or modify their text label or their icon.

## Signals

| currentChanged (int index)

## Methods

| __init__ (self, QGraphicsWidget parent=0)
int | addTab (self, QIcon icon, QString label, QGraphicsLayoutItem content=0)
int | addTab (self, QString label, QGraphicsLayoutItem content=0)
| changeEvent (self, QEvent event)
int | count (self)
int | currentIndex (self)
QGraphicsWidget | firstPositionWidget (self)
int | insertTab (self, int index, QIcon icon, QString label, QGraphicsLayoutItem content=0)
int | insertTab (self, int index, QString label, QGraphicsLayoutItem content=0)
bool | isTabBarShown (self)
bool | isTabHighlighted (self, int index)
QGraphicsWidget | lastPositionWidget (self)
KTabBar | nativeWidget (self)
| removeTab (self, int index)
| resizeEvent (self, QGraphicsSceneResizeEvent event)
| setCurrentIndex (self, int index)
| setFirstPositionWidget (self, QGraphicsWidget widget)
| setLastPositionWidget (self, QGraphicsWidget widget)
| setStyleSheet (self, QString stylesheet)
| setTabBarShown (self, bool show)
| setTabHighlighted (self, int index, bool highlight)
| setTabIcon (self, int index, QIcon icon)
| setTabText (self, int index, QString label)
QString | styleSheet (self)
QGraphicsLayoutItem | tabAt (self, int index)
QIcon | tabIcon (self, int index)
QString | tabText (self, int index)
QGraphicsLayoutItem | takeTab (self, int index)
| wheelEvent (self, QGraphicsSceneWheelEvent event)

## Signal Documentation

currentChanged | ( | int | index
| ) |  |  |

Emitted when the active tab changes

Parameters:

  | index | the newly activated tab

Signal syntax:
  `QObject.connect(source, SIGNAL("currentChanged(int)"), target_slot)`

## Method Documentation

__init__ | ( | self, |
|  | QGraphicsWidget | parent=0
| ) |  |  |

Constructs a new TabBar

Parameters:

  | parent | the parent of this widget

int addTab | ( | self, |
|  | QIcon | icon,
|  | QString | label,
|  | QGraphicsLayoutItem | content=0
| ) |  |  |

Adds a new tab in the last position This is an overloaded member provided for convenience equivalent to addTab(QIcon(), label, page)

Parameters:

  | label | the text label of the tab
  | content | the page content that will be shown by this tab

Returns:
  the index of the inserted tab

int addTab | ( | self, |
|  | QString | label,
|  | QGraphicsLayoutItem | content=0
| ) |  |  |

Adds a new tab in the last position This is an overloaded member provided for convenience equivalent to addTab(QIcon(), label, page)

Parameters:

  | label | the text label of the tab
  | content | the page content that will be shown by this tab

Returns:
  the index of the inserted tab

changeEvent | ( | self, |
|  | QEvent | event
| ) |  |  |

int count | ( |  | self ) |

Returns:
  the number of tabs in this tabbar

int currentIndex | ( |  | self ) |

Returns:
  the index of the tab currently active

QGraphicsWidget firstPositionWidget | ( |  | self ) |

Returns:
  the widget in the first position

Since:
  4.6

int insertTab | ( | self, |
|  | int | index,
|  | QIcon | icon,
|  | QString | label,
|  | QGraphicsLayoutItem | content=0
| ) |  |  |

Adds a new tab in the desired position This is an overloaded member provided for convenience equivalent to insertTab(index, QIcon(), label);

Parameters:

  | index | the position where to insert the new tab, if index <=0 will be the first position, if index >= count() will be the last
  | label | the text label of the tab
  | content | the page content that will be shown by this tab

Returns:
  the index of the inserted tab

int insertTab | ( | self, |
|  | int | index,
|  | QString | label,
|  | QGraphicsLayoutItem | content=0
| ) |  |  |

Adds a new tab in the desired position This is an overloaded member provided for convenience equivalent to insertTab(index, QIcon(), label);

Parameters:

  | index | the position where to insert the new tab, if index <=0 will be the first position, if index >= count() will be the last
  | label | the text label of the tab
  | content | the page content that will be shown by this tab

Returns:
  the index of the inserted tab

bool isTabBarShown | ( |  | self ) |

Returns:
  true if the tabbar is shown

Since:
  4.3

bool isTabHighlighted | ( | self, |
|  | int | index
| ) |  |  |

Returns:
  if the tab at index is highlighted

Since:
  4.7

QGraphicsWidget lastPositionWidget | ( |  | self ) |

Returns:
  the widget in the last position

Since:
  4.6

KTabBar nativeWidget | ( |  | self ) |

Returns:
  the native widget wrapped by this TabBar

removeTab | ( | self, |
|  | int | index
| ) |  |  |

Removes a tab, contents are deleted

Parameters:

  | index | the index of the tab to remove

resizeEvent | ( | self, |
|  | QGraphicsSceneResizeEvent | event
| ) |  |  |

setCurrentIndex | ( | self, |
|  | int | index
| ) |  |  |

Activate a given tab

Parameters:

  | index | the index of the tab to activate

setFirstPositionWidget | ( | self, |
|  | QGraphicsWidget | widget
| ) |  |  |

Set a widget to be displayed on one side of the TabBar, depending on the LayoutDirection and the Shape.

Parameters:

  | widget | the widget to be displayed. Passing 0 will show nothing. Any previous widget will be deleted.

Since:
  4.6

setLastPositionWidget | ( | self, |
|  | QGraphicsWidget | widget
| ) |  |  |

Set a widget to be displayed on one side of the TabBar, depending on the LayoutDirection and the Shape.

Parameters:

  | widget | the widget to be displayed. Passing 0 will show nothing. Any previous widget will be deleted.

Since:
  4.6

setStyleSheet | ( | self, |
|  | QString | stylesheet
| ) |  |  |

Sets the stylesheet used to control the visual display of this TabBar

Parameters:

  | stylesheet | a CSS string

setTabBarShown | ( | self, |
|  | bool | show
| ) |  |  |

shows or hides the tabbar, used if you just want to display the pages, when the tabbar doesn't have content pages at all this function has no effect

Parameters:

  | show | true if we want to show the tabbar

Since:
  4.3

setTabHighlighted | ( | self, |
|  | int | index,
|  | bool | highlight
| ) |  |  |

Highlight the specified tab

Parameters:

  | index | of the tab to highlight
  | highlight | true if it should be highlighted, wrong if not

Since:
  4.7

setTabIcon | ( | self, |
|  | int | index,
|  | QIcon | icon
| ) |  |  |

Sets an icon for a given tab

Parameters:

  | index | the index of the tab to modify
  | icon | the new icon for the given tab

setTabText | ( | self, |
|  | int | index,
|  | QString | label
| ) |  |  |

Sets the text label of the given tab

Parameters:

  | index | the index of the tab to modify
  | label | the new text label of the given tab

QString styleSheet | ( |  | self ) |

Returns:
  the stylesheet currently used with this widget

QGraphicsLayoutItem tabAt | ( | self, |
|  | int | index
| ) |  |  |

Returns the contents of a page

Parameters:

  | index | the index of the tab to retrieve

Since:
  4.4

QIcon tabIcon | ( | self, |
|  | int | index
| ) |  |  |

Returns:
  the current icon for a given tab

Parameters:

  | index | the index of the tab we want to know its icon

QString tabText | ( | self, |
|  | int | index
| ) |  |  |

Returns:
  the text label of the given tab

Parameters:

  | index | the index of the tab we want to know its label

QGraphicsLayoutItem takeTab | ( | self, |
|  | int | index
| ) |  |  |

Removes a tab, the page is reparented to 0 and is returned

Parameters:

  | index | the index of the tab to remove

Since:
  4.4

wheelEvent | ( | self, |
|  | QGraphicsSceneWheelEvent | event
| ) |  |  |