This is the correct operation. The screen change is relative to the ScreenManager the screen belongs to. You are setting the initial state as on the “first” screen. So on_enter is not firing. As a work around you could create a dummy screen as initial screen, and have it switch to the “first” screen causing on_enter to fire.
--
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/CAFYkXjkX0N7-djFd3aoCKcjQzgBuF%2BqBqnqaZW2RXe61zjFMzA%40mail.gmail.com.
From any screen you can access that screens manager with it’s manager attribute, self.manager.
If the root widget is a screenmanager, you can access it from kv as app.root or from python as:
app = App.get_running_app()
manager = app.root
I’ll see if I can put together an example that does what you’re looking for.
--
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/CAFYkXjkhPw-%3DcLv6xbkDewdsVK6iS4F8KfO2e8yWok69htvCbQ%40mail.gmail.com.
You can use the on_kv_post event to change the screen… example below:
from kivy.app import App
from kivy.lang import Builder
kv = """
<DummyScreen@Screen>:
on_kv_post: self.manager.current = 'First' # change screen after kv is initialized
Label:
text: root.name
<LabelScreen@Screen>:
on_enter: print(f'Screen {self.name} entered')
BoxLayout:
orientation: 'vertical'
Label:
text: root.name
Button:
size_hint_y: None
height: 48
text: 'Next'
on_release: root.manager.current = root.manager.next()
ScreenManager:
DummyScreen:
name: 'Dummy'
LabelScreen:
name: 'First'
LabelScreen:
name: 'Second'
LabelScreen:
name: 'Third'
"""
class ScreenEnterExampleApp(App):
def build(self):
return Builder.load_string(kv)
ScreenEnterExampleApp().run()
From: Tomek CEDRO
Sent: Sunday, August 21, 2022 12:01 PM
To: kivy-...@googlegroups.com
--
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/CAFYkXjkhPw-%3DcLv6xbkDewdsVK6iS4F8KfO2e8yWok69htvCbQ%40mail.gmail.com.
😊
-Elliot
From: Tomek CEDRO
Sent: Sunday, August 21, 2022 3:51 PM
To: kivy-...@googlegroups.com
Subject: Re: [kivy-users] Screen.on_enter() not called in the firstscreenafterapp start
On Sun, Aug 21, 2022 at 9:52 PM Elliot Garbus wrote:
--
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/CAFYkXj%3DcsZQRm0TOgaf4RRUwJyiWE%2B%2B00C1Bw8Zbc_ijfw3TUA%40mail.gmail.com.