beginner: spinner text align: left?

1,147 views
Skip to first unread message

Sven Petersen

unread,
Oct 15, 2012, 4:19:38 AM10/15/12
to kivy-...@googlegroups.com
Hello,

it would be nice if someone could tell me how I can align the text of the Spinner's Dropdown Items left.


Thanks

Sven Petersen

unread,
Oct 15, 2012, 6:53:17 AM10/15/12
to kivy-...@googlegroups.com

additionally, how can I increase the font size of the Spinner Items?
If I set the font_size property of the Spinner, only the font size of the Spinner Button itself is set, not that of the Items.

Gabriel Pettier

unread,
Oct 15, 2012, 7:26:05 AM10/15/12
to kivy-...@googlegroups.com
Le 15/10/2012 10:19, Sven Petersen a �crit :
> Hello,
>
> it would be nice if someone could tell me how I can align the text of
> the Spinner's Dropdown Items left.
>
>
> Thanks --
>
>
Well, like any Label, no? look at examples/widgets/text_align.py example
to understand how text align works (you have to manage both the texture
size and the valign value of the Label).

Sven Petersen

unread,
Oct 15, 2012, 7:48:13 AM10/15/12
to kivy-...@googlegroups.com
Hello,

thanks for your answer. What you suggested works for the "Button" of the Spinner, but how can I set the Properties for the Items of the Spinner?

  item_list = [ 'A', 'B', 'C']

            spinner = Spinner(
                text='Choose an Item',
                text_size=(500, None),
                size_hint=(1, 1),
                halign='left',
                values= item_list,
                size=(520, 80),
                pos=(300, 500),
                font_size=24,
                )

text_size, halign and font_size are only applied to the "Choose an Item" Button, not to the A, B, C Items of the List.
Sorry but I don't know how to do this with the Spinner Widget, or will I have to use the DropDown Widget instead? 

Gabriel Pettier

unread,
Oct 15, 2012, 8:29:31 AM10/15/12
to kivy-...@googlegroups.com
Oh, sorry, i mixed with the DropDown, my bad… what you want here is to
use your own class to display the options, you can subclass Label, do
this change, you can do it from kv as:

MyOptionLabel:
text_size = self.width, None
valign = 'left'

and pass MyOptionLabel as option_cls parameter to the Spinner()

that should do the trick.
> --
>
>


Gabriel Pettier

unread,
Oct 15, 2012, 8:30:32 AM10/15/12
to kivy-...@googlegroups.com
maybe subclassing from SpinnerOption would be better though, i didn't
really try either way :).

Le lun. 15 oct. 2012 13:48:13 CEST, Sven Petersen a écrit :
> --
>
>


Sven Petersen

unread,
Oct 15, 2012, 10:01:00 AM10/15/12
to kivy-...@googlegroups.com
thank you very much!

yes, adding

Builder.load_string('''
<SpinnerOption>:
    halign: 'left'
    font_size: 16
    ...

solved my problem.


2012/10/15 Gabriel Pettier <gabriel...@gmail.com>
Reply all
Reply to author
Forward
0 new messages