class tab_panel.TabPanel(Widget)

A TabPanel is a widget that manages a collection of pages and displays one of them at a time. Switching between pages is accomplished by means of a row of tabs at the top of the TabPanel, one for each page. Clicking on a tab brings its corresponding page to the front.

Tab background colour determination

Normally, the background of each tab is filled with the bg_color of its associated page, so that it appears to be an extension of it. If the page has a tab_bg_color attribute, that colour is used instead of its bg_color. If the page specifies neither of these, the default_tab_bg_color of the TabPanel is used.

Constructor

TabPanel(pages = None)
The pages, if provided, should be a sequence of (title, widget) pairs, which will be added as by the add_page() method.

Theme Properties

tab_font
Font in which to display the page titles in the tabs.

tab_height
Height of the tabs.

tab_border_width
Width of the border, if any, to draw around each tab.

tab_spacing
Width of space to leave between adjacent tabs.

tab_margin
Width of space to leave before the first tab and after the last tab.

tab_fg_color
Colour in which to display the page titles.

default_tab_bg_color
Colour with which to fill the background of any tab whose page does not specify a tab colour.

tab_area_bg_color
Colour with which to fill any background areas of the tab region not covered by a tab.

tab_dimming
Factor by which to dim the background colour of tabs other than the currently selected tab. Range 0.0 to 1.0.

Attributes

pages
Read only. List of widgets that have been added as pages. Don't modify this list directly; use the add_page() and remove_page() methods.
current_page
Read only. The currently displayed page widget. Use the show_page() method to change this.

Methods

add_page(title, widget)
Adds the given widget as a new page, with the specified title to be displayed in its tab. Note: The widget should not also be added using add(); the TabPanel will do that itself when appropriate.

remove_page(
widget)
Removes the specified page, if present.

show_page(
widget)
Makes the specified page the currently displayed page.

content_size()
Returns a tuple (width, height) of the size of the content area, i.e. the area that a page will take up when it is displayed.

content_rect()
Returns a Rect representing the content area in the local coordinate system of the TabPanel.

page_height()
Returns the height of a page (equal to the height of the content_rect()).
---