multiple screen manager and some issues with kivy

187 views
Skip to first unread message

satyam yadav

unread,
Jul 6, 2022, 3:41:27 PM7/6/22
to Kivy users support
So , I have attached a python file which have only ui part of the app without the api calls for the privacy reasons.

I have build the whole app but after all this i have encountered  some of the basic issues which i need to solve for the successful execution of the app.

Things to achieve :
1. Whenever I login , the text file is created which will have the refresh token  because it will help in retrieving the the localid,  idToken associated with it  So now whenever i startup the app because the text file have a refresh tokenn i should call the api and save the data associated with it and then  get the Main screen on starting up the app which i am not able to achieve.

2. When app is in background  , i am not able to update the refresh token and it is neccesary to update on resume function because the  opened screen if need to show some data of the user the refresh token can not be used as it is expired and then whats the point and one more thing the , when i am resuming the app the pre_enter function of the screen is not getting trigered , so even if  i call an api for the new idtoken and refresh token , the screen of the app will not be getting called so there will not be any change.

3. So ,when i am logging in main screen gets called which have a child widget  of screen manager class defined in python  code referenced as id : after_login_manager   which have other screen child widget . Different screens (utility and notification). Whenever i open main screen the utility screen gets called up but its pre enter function does not but the pre_enter function of main gets called up, so i want to call the utility screen after successful login which I am not able to achieve.

4. As the  utility screen appeared as default when i am calling the main screen , then i want to update the x , y widget which label widget in the first screen of the screen manager in navigation layout i.e. Home screen which are referenced as
 my_account_card_layout_total_account and  my_account_card_layout_itachi_count
respectively ,  which i am not sure how i can update .

Issues which came during the solving the above problems:
1.  When i am  running this app , so i have three screen manager one as a parent screen manager and two are nested  , so whenever i start my app in local machine  , (on_pre_enter) function of the first screen of all the screen manager is running.

2. I am not able to access widgets of different classes from different classes as i want to update the x,y values in the Home screen which is inside the screen manager of NavigationLayout which the the child widget of Boxlayout inside Utility screen.

How i can solve this problems ,  during this i have realized all these problems and  understood that these are sequential problems and i have also mentioned in sequentially. Please look into this and  I will be obliged.
navigation_screen_problem.py

satyam yadav

unread,
Jul 6, 2022, 3:46:04 PM7/6/22
to Kivy users support
Please suggest any change in  structural design of the code if  needed  , and ui of the app as well. and problems i have already stated above.

Robert

unread,
Jul 6, 2022, 9:30:26 PM7/6/22
to Kivy users support
It seems the basic issue is you are commingling: cloud storage issues, with screen manager issues, and OOP scope issues.
The easiest way to un-mangle these is with separate small examples.

The cloud storage usage issue is really a Kivy lifecycle issue:

The short answer to the cloud storage token issue is: it needs to be read from the file and then refreshed by the server at app resume.

This case should also be checked at app start since you don't know if Android stopped the app while it was paused or if this is the first time the app was run (but in case it was stopped, this is why the app saved the token to a file rather than leave it in memory).

All of this is independent of whatever your UI does, it depends only on this diagram https://kivy.org/doc/stable/guide/basic.html#kivy-app-life-cycle

Maybe somebody else wants to look at the SM and OOP issues?

Elliot Garbus

unread,
Jul 6, 2022, 11:31:04 PM7/6/22
to kivy-...@googlegroups.com

Robert covered items 1 & 2;

 

Items 3 & 4:

 

There are a few things going on here. 

  • You can fix and simplify some of these issues by getting rid of the main screen and adding the 2 Screens under Main, into your root ScreenManager.  There is no visual reason or any other reason to nest these ScreenManagers.
  • The on_pre_enter event is firing relative to the ScreenManager.  You have Utility under the screen manager called After_login_manager.   Utility is not changing relative to it’s ScreenManager, so the event is not firing.  The on_pre_enter event for Main will fire.  You should move Utility and Notification under the Root Screen Manager.  When you move Utility out the the main screenmanager, you will get the on_pre_enter event as you expect.
  • You are giving each screen an id.  This is unusual, and not required.  You should access the screens with their names, through the screenmanager they are under.
  • For example, lets access the email TextInput on the Forget screen.
    • app.root.get_screen(‘forget_password’).ids.email.text
  • If you have nested screenmanagers, you would just add them to the list.. for example:
    • App.root.get_screen(‘main’).ids.after_login_manager.get_screen(‘utility’).ids. screen_manager_utility.get_screen(‘home’).ids. my_account_card_layout_total_account.text

 

You can simplify this long string by an appropriate element as a kivy object property.  For example each Screen has a manager attribute that is the screen manager the screen is under.  You could create an object property for some of your classes and set it to a value you need to access to shorten some of these kv strings.

 

In short:

  1. get rid of the Main Screen and put the Utility and Navigation Screens under the root ScreenManger.  This will fix some issues and simplify others. 
  2. Use the screen names and the screen manager method get_screen(‘screen name’) to access the screens under a manager.
  3. You can remove the id you have associated with each screen, just use the name.
  4. Nested screens are no different than any other widget, you just need to keep appending to the kv string to access the desired widget.

--
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/a38809d4-3404-40d9-a7b3-2a3272b6ee58n%40googlegroups.com.

 

satyam yadav

unread,
Jul 7, 2022, 2:24:21 AM7/7/22
to Kivy users support
thankyou  Elliot and Robert , I understood elliot your approach but the whole thing together is still not understandable to me so i think i have to ask individual questions.
Reply all
Reply to author
Forward
0 new messages