Placement of Spinner

7 views
Skip to first unread message

Dan Moormann

unread,
Jul 1, 2024, 11:57:52 PM (24 hours ago) Jul 1
to Kivy users support
Trying to create a "Settings" function to my Grid app.  First step is to build a screen to display and/or update the settings values.  I've got the basics down but cannot figure out why the spinner always drops to the bottom of the screen.  It's not very pretty (yet) but I can fix that later.  I know I need to read/write/initialize to/from a settings file but again later (unless you have any suggestions).

I basically copied and tweaked the boxes and colors functions from Main.

Main concern - what's wrong with spinner?

Click on Flash Type (on Main) then select Settings.

linenum.py
grid.py
grid.kv

ElliotG

unread,
7:10 PM (4 hours ago) 7:10 PM
to Kivy users support
The spinner is in a GridLayout.  The way you have the Screen setup the GridLayout as a a top row that has a height of 50, and the next row, takes up the rest of the screen.  The Spinner is sitting in the bottom of that second row in the GridLayout.  
You could put a RelativeLayout in the GridLayout, and the Spinner in the RealativeLayout, then set the pos of the Spinner as desired. 

Something like this:
                            GridLayout:
                cols: 2
                rows: 2
                pos_hint_x: {'right':.75}
                Button:
                    id: button_top
                    text: 'Initial\n# of Boxes'
                    size_hint: None, None
                    size: 130,50
                    background_color: 'aquamarine'
                    background_normal: ''
                    color: 'black'
                    on_press: spin.is_open=True
                Button:
                    text: 'Starting Color orange'
                    size_hint: None, None
                    size: 237,50
                    background_color: 'orange'
                    background_normal: ''
                    color: 'black'
                RelativeLayout:
                    Spinner:
                        id: spin
                        background_color: 'aquamarine'
                        background_normal: ''
                        color: 'black'
                        text: '16'
                        size_hint: None,None
                        size: 120,48
                        top: button_top.y
                        values: '4','9','16','25','36','49','64','81','100','144','169','196','225','256'
                        on_text: print(self.text)




I think a better choice would be to use a different set of layouts.
Reply all
Reply to author
Forward
0 new messages