Handling widget layers in .kv file

1,027 views
Skip to first unread message

Gleb Pushkov

unread,
Mar 14, 2013, 6:15:33 AM3/14/13
to kivy-...@googlegroups.com
Hello! I have defined interface of my app in .kv file, but I have some problems with layers (my custom TreeView's children appears under the buttons). When my application interface was defined in .py files - I've used index: add_widget(myWidget, index=1) - and it worked. But how can I make same trick in .kv file? Thanks!

Akshay Arora

unread,
Mar 14, 2013, 9:22:35 AM3/14/13
to kivy-...@googlegroups.com

In kv, widget's should be added in the order they are declared, so just declare the widgets you want on top last.

Best Regards

On Thu, Mar 14, 2013 at 3:45 PM, Gleb Pushkov <gle...@gmail.com> wrote:
Hello! I have defined interface of my app in .kv file, but I have some problems with layers (my custom TreeView's children appears under the buttons). When my application interface was defined in .py files - I've used index: add_widget(myWidget, index=1) - and it worked. But how can I make same trick in .kv file? Thanks!

--
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.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Gleb Pushkov

unread,
Mar 14, 2013, 1:35:20 PM3/14/13
to kivy-...@googlegroups.com

But defining of widget underneath of another widgets also changes order of elements. My AutocompleteTextInput widget should be at the top and on the top layer. Under it should go buttons and text inputs…

BoxLayout:
            id
: request_area
            orientation
:'vertical'
            size_hint
:0.8, 0.8
            padding
:20
            spacing
:10              
            pos_hint
: {'x': 1, 'y': 1}

           
AutocompleteTextInput:
                id
:autocompl_wordx
                multiline
:False
                border
:10, 10, 10, 10
                font_size
:20
                pos_hint
: {'x': .22, 'y': .5}
                size_hint
:0.5, 0.3
                 


           
BoxLayout:
                id
: boxlayout_dropdown
                orientation
:'horizontal'
                   

               
Button:
                   
     
               
Button:
                   
         
               
Button:
                   


           
TextInput:
                             


So, how can I make AutocompleteTextInput widget at the top and on the top layer?…Thanks!

Gleb Pushkov

unread,
Mar 16, 2013, 8:40:56 AM3/16/13
to kivy-...@googlegroups.com
I've tried to handle it with anchor layout, but it doesn't work. I've added two anchor layouts - first for buttons and other stuff on the bottom        

       AnchorLayout:
                anchor_x: 'center'
                anchor_y: 'bottom'
                ...
and below I've defined layout with my autocomplete widget:             

       AnchorLayout:
                anchor_x: 'center'
                anchor_y: 'top'

But anyway, second AnchorLayout still under the first. I think some kind of z-index should be implemented in kivy, because I can't see another way to solve it( 

Akshay Arora

unread,
Mar 16, 2013, 10:07:52 AM3/16/13
to kivy-...@googlegroups.com
Are you looking for something like this?

http://wstaw.org/m/2013/03/16/snapshot2.png

Best Regards

--

Gleb Pushkov

unread,
Mar 16, 2013, 4:10:47 PM3/16/13
to kivy-...@googlegroups.com
FloatLayout makes widget totally separate from main layout...In my case children in toggled list appeared under buttons so I've fixed my problem with function, which created instance of widget in python-code and added it with add_widget with index parameter. And that function was called from my .kv... Not pretty... It would be much better to have "index" property in .kv file. When elements loads from .kv file - add_widget function is called, so it would be great if in future we will have opportunity to add this index as a property of element in .kv files.  

Gleb Pushkov

unread,
Mar 16, 2013, 4:11:35 PM3/16/13
to kivy-...@googlegroups.com
And...thanks for helping)

Maxime Haineault

unread,
May 4, 2015, 12:18:57 AM5/4/15
to kivy-...@googlegroups.com
Just ran into the same problem :(

Philippe Faure

unread,
Apr 19, 2017, 9:59:17 PM4/19/17
to Kivy users support
Can you please post a snippet of your code solution.
Reply all
Reply to author
Forward
0 new messages