Open Popup on top of Root Widget on App Startup

639 views
Skip to first unread message

Strattos A.

unread,
Dec 18, 2013, 3:39:45 AM12/18/13
to kivy-...@googlegroups.com
Good day Team,

I am trying to get my App create a Popup on boot which will be placed on top of all my sub-widgets of my canvas.

My related portion in my .py file is as follows:

class Popup(Popup):
    pass

class convApp(App):
    
    def build(self):
        Popup().open()
        return YFC()

My .kv file is as follows:

<Popup>:
title: 'Useful information'
size_hint: .5, .5
<YFC>:
    orientation: 'vertical'
    ...........

Doing the above is the only way I found to successfully initiate the Popup.
The problem though is that the Popup loads at the background behind all sub widgets. If I click on any location of it the popup closes as should.

The concept is to give to the user some hints about the App, through a popup (splash screen) when the App starts and when the user chooses to dismiss the popup to continue with the App which will be already loaded behind the Popup.
Any hints and tips?

Ben Rousch

unread,
Dec 18, 2013, 7:54:24 AM12/18/13
to kivy-...@googlegroups.com
Have you tried loading the app normally, then loading the popup?


--
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.



--
 Ben Rousch
   bro...@gmail.com
   http://clusterbleep.net/

Strattos A.

unread,
Dec 18, 2013, 8:06:40 AM12/18/13
to kivy-...@googlegroups.com
Hi Ben,

class convApp(App):
    def show_popup(self):
        Popup().open()
        
    def build(self):
        return YFC()
OK to define a call for popup to open how to call it though? Where to bind it?

Ben Rousch

unread,
Dec 18, 2013, 8:08:44 AM12/18/13
to kivy-...@googlegroups.com
Try to schedule it via a clock in the root widget after everything else is loaded

Strattos

unread,
Dec 18, 2013, 8:23:24 AM12/18/13
to kivy-...@googlegroups.com
Nothing happens (I have imported Clock).I might not getting something here. Where am I wrong?

class Popup(Popup):
    pass

class convApp(App):
    def show_popup(self):
        Popup().open()
        
    def build(self):
        return YFC()
        Clock.schedule_once(show_popup, 1)




--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/iYXrxojphj0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
                                                                                                                    
Stratos F. Arvanitidis

Kovak

unread,
Dec 18, 2013, 6:13:43 PM12/18/13
to kivy-...@googlegroups.com
    def build(self):
        return YFC()
        Clock.schedule_once(show_popup, 1)

needs to be

    def show_popup(self, dt):
        Popup().open()


    def build(self):
        Clock.schedule_once(self.show_
popup, 1)
        return YFC()
       

Strattos A.

unread,
Dec 19, 2013, 3:31:45 AM12/19/13
to kivy-...@googlegroups.com
Thanks Kovak. It works like that!

Can you tell way this works:

<Popup>:
    #id: myPopup
    title: 'Useful information'
    title_size: '20sp'
    size_hint: .5, .5
    #size: (400, 400)
    content: lblContent
    Label:
        id: lblContent
        text: 'Did you know that...'

while this doesn't:

<Popup>:
    #id: myPopup
    title: 'Useful information'
    title_size: '20sp'
    size_hint: .5, .5
    #size: (400, 400)
    content:
          Label:
              text: 'Did you know that...'

giving the following error:

[WARNING           ] stderr:     text: 'Did you know that...'
[WARNING           ] stderr:         ^
[WARNING           ] stderr: SyntaxError: invalid syntax


If I build the Popup in the .py file following the documentation, I could nest the above as follows:
popup = Popup(content=Label(text='Hello world'))

Based on that I decided to do the same in the .kv file. But this does not work unless I create the Label at the same level with all the other Popup attributes and refer to its ID in the Popup content attrib.
Isn't it weird ?
Reply all
Reply to author
Forward
0 new messages