0

I have vertical tabs but want to 'rotate' the tab labels so that these read horizontally. How could this be done?

The kivy file contains:

TabbedPanel:
    id: tab_panel
    tab_pos: 'left_top'
    do_default_tab: False

    TabbedPanelItem:
        text: '1'

    TabbedPanelItem:
        text: '2'

    TabbedPanelItem:
        text: '3'
Bill Bridge
  • 821
  • 1
  • 9
  • 30
  • This is not directly supported by `TabbedPanel`, but could be added. You might submit a feature request at https://github.com/kivy/kivy/issues. – kitti May 24 '16 at 22:24

1 Answers1

0

Edit: Actually, it IS possible!

TabbedPanelItem:
    text: '2'
    canvas.before:
        PushMatrix
        Rotate:
            angle: -90
            axis: 0,0,1
            origin: self.center
    canvas.after:
        PopMatrix

With current api impossible. And it'll be really ugly if you manage to do it, because it'll stretch the tab-header and make it a square or even another, 90° rotated rectangle, which will screw your Layout as much as possible - the original tab will look like a casual Button and whole TabbedPanel as a beginner's try to make html page if you don't want to limit yourself to 3-4 characters with current font size. Just saying.

You may try to edit the source and one of the ways how to do it directly is making a custom ToggleButton from which TabbedPanelHeader inherits and rotate it with Push/PopMatrix().

The other (and more reasonable) way would be to make tabs look like this:

t|
a| content
b|
_|

i.e. text going up -> down, though I don't know how to do it except rotating the whole thing and work with characters like this: t\na\nb

Peter Badida
  • 11,310
  • 10
  • 44
  • 90
  • I agree that for ordinary text this will look very ugly. But when you want to just number the tabs, this would increase readability. – Bill Bridge May 24 '16 at 22:49
  • Yup, that's why I wrote about the limitation of 3-4 characters(so it wouldn't stretch much) and gave an example of how it could work for long(er) words :P anyway, custom widget and `Push&PopMatrix`, which you can see [here](http://stackoverflow.com/questions/17674736/kivy-how-to-rotate-a-picture). [Place for widget](https://github.com/kivy/kivy/blob/master/kivy/uix/tabbedpanel.py#L146) – Peter Badida May 24 '16 at 22:51
  • The answer helps but as said only for very size limited text items. – Bill Bridge Nov 14 '16 at 23:00