kivy: multiple header lines in tabbedpanel

By default, the TabbedPanel uses a GridLayout with the restriction of one row and 99 columns for the headers. This should be sufficient for most applications. However, it is more common to add a second row for the tabbed headers instead of trying to fit them all into one single row. Unfortunately, the way to do it is undocumented.

tabbed

You have to override the default settings for the TabbedPanelStrip class. Here is the only way I could think of (editing the kivy source is not an option!): I'm assuming you are using a *.kv file already. Add the following lines:

<TabbedPanelStrip>:
    rows: 2
    cols: 8
    spacing: 5

Now you can use your new functionality without major changes in your code. The only thing you have to keep in mind is the height adjustment:

tp = TabbedPanel(tab_height=120, tab_width=30, do_default_tab=False, tab_pos='top_mid')

You may also like...

1 Response

  1. D.M.Bailey says:

    Almost worked.

    Had to change _update_tab_width in TabbedPanel

    tsw = self.tab_width * len(self._tab_strip.children)
    to
    tsw = self.tab_width * min(len(self._tab_strip.children), self._tab_strip.cols)

Leave a Reply

Your email address will not be published.