TabbedPanelItem text position

42 views
Skip to first unread message

Luke Smith

unread,
May 14, 2022, 9:48:10 PM5/14/22
to Kivy users support
I have a Tabbed Panel design and have added the labels but they are left aligned, rather than center aligned. I have tried all different approaches but can't change the alignment of the label on the tab.

Any suggestions on how to change this?

Thanks

Elliot Garbus

unread,
May 14, 2022, 10:55:55 PM5/14/22
to kivy-...@googlegroups.com

Share your code, running the “simple example” from the docs,  the text on the Labels on the tabs are centered.  The tabs are derived from ToggleButtons.

 

'''
TabbedPanel
============

Test of the widget TabbedPanel.
'''

from kivy.app import App
from kivy.uix.tabbedpanel import TabbedPanel
from kivy.lang import Builder

Builder.load_string(
"""

<Test>:
    size_hint: .5, .5
    pos_hint: {'center_x': .5, 'center_y': .5}
    do_default_tab: False

    TabbedPanelItem:
        text: 'first tab'
        Label:
            text: 'First tab content area'
    TabbedPanelItem:
        text: 'tab2'
        BoxLayout:
            Label:
                text: 'Second tab content area'
            Button:
                text: 'Button that does nothing'
    TabbedPanelItem:
        text: 'tab3'
        RstDocument:
            text:
                '
\\n'.join(("Hello world", "-----------",
                "You are in the third tab."))

"""
)


class Test(TabbedPanel):
   
pass


class
TabbedPanelApp(App):
   
def build(self):
       
return Test()


if __name__ == '__main__':
    TabbedPanelApp().run()

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/b5f9bda8-a11b-4b79-8f5f-733b344a3872n%40googlegroups.com.

 

Luke Smith

unread,
May 15, 2022, 12:49:14 AM5/15/22
to Kivy users support
<MyLayout>
    id: my_widget
    tab_pos: 'left_bottom'
    tab_width: 150

    pos_hint: {'center_x': .5, 'center_y': .5}
    do_default_tab: False

    TabbedPanelItem:
        text: "Create Entity"

It still left aligns the label

tabs.png

Elliot Garbus

unread,
May 15, 2022, 4:29:05 PM5/15/22
to kivy-...@googlegroups.com

I’m running kivy 2.1; I do not see that issue.  Please share a runnable program.

In the example below, I changed the tab_pos to match your example, but do not have the same issue.

 

 

 

from kivy.app import App
from kivy.lang import Builder

kv =
"""
AnchorLayout:
    TabbedPanel:
        size_hint: .9, .9
        do_default_tab: False
        tab_pos: 'left_bottom'
        tab_width: 150

        TabbedPanelItem:
            text: 'first tab'
            Label:
                text: 'First tab content area'
        TabbedPanelItem:
            text: 'tab 2'
            Label:
                text: 'Second tab content area'
        TabbedPanelItem:
            text: 'tab3'
            Label:
                text: 'Third tab content area'
"""


class TabbedPanelApp(App):
   
def build(self):
       
return Builder.load_string(kv)


Reply all
Reply to author
Forward
0 new messages