community
community copied to clipboard
TabbedPanel button text is rotated when 'tab_pos: "left_top"' is used
Software Versions
- Python: 3.12.2
- OS: Windows 10 up to date
- Kivy: 2.3.0
- Kivy installation method: Pycharm via pip
Describe the bug
When a Tabbed Panel is defined in the kv file, with the option 'tab_pos: "left_top"', the resulting buttons are rotated 90 degrees such that the text runs from bottom to top on the screen. The rotation of the buttons is not readily changeable.
The issue tracker is a tool to address bugs only (search known bugs: https://git.io/vM1iE). Please use the #support Discord channel at https://chat.kivy.org/ or Stack Overflow for support questions, more information at https://git.io/vM1yQ.
Expected behavior The button text should be able to be horizontal or vertical as needed.
A partial solution involving canvas.before: rotation results in a button that looks incorrect if the button is not square to begin with.
To Reproduce
from kivy.lang import Builder
from kivy.uix.tabbedpanel import TabbedPanel
from kivy.app import App
Builder.load_string('''
<WrongTab>:
do_default_tab: False
tab_pos: "left_top"
tab_height: 150
tab_width: 50
TabbedPanelItem:
text: "first heading"
''')
class WrongTab(TabbedPanel):
pass
class TestApp(App):
def build(self):
return WrongTab()
if __name__ == "__main__":
TestApp().run()
See below for current partial solution:
Code and Logs and screenshots
from kivy.lang import Builder
from kivy.uix.tabbedpanel import TabbedPanel
from kivy.app import App
Builder.load_string('''
<WrongTab>:
do_default_tab: False
tab_pos: "left_top"
tab_height: 150
tab_width: 50
TabbedPanelItem:
text: "first heading"
canvas.before:
PushMatrix
Rotate:
angle: -90
origin: self.center
canvas.after:
PopMatrix
''')
class WrongTab(TabbedPanel):
pass
class TestApp(App):
def build(self):
return WrongTab()
if __name__ == "__main__":
TestApp().run()
Additional context The background issue can be more clearly seen if the rotation angle is set to -45
If you look at the tabbed_panel_showcase.py example, you can see how custom tabs can be rotated using a scatter. https://github.com/kivy/kivy/blob/master/examples/widgets/tabbed_panel_showcase.py