-
Notifications
You must be signed in to change notification settings - Fork 55
Home
- Our First Dev Sprint meant to get people familiarized with kivy.
After this first Devspring it was decided that we would start working on the app from scratch.
For this purpose the master branch was emptied and we have started with blank dir.
Step 1: We setup a basic structure for the app
PyCon-Mobile-App
|
|___ LICENSE
|___ Makefile
|___ README.md
|___ eventsapp
|___ main.py: "This is the main entry point of our application"
|___ uix: "This is where our user interface elements go."
|___ screens: "This is where all our UI screens of the app go."
|
|___ tools: "This is where all our tools including assets etc go."
|___ images: "This is where all our image assets go."
|___ raw_assets: "This is where our raw assets from the design team exist."
|___ tests: "All our tests go here"
This is the current app structure, Currently the main.py just has the following data.
from kivy.app import App
class EventsApp(App):
'''This is our entry point for the application
'''
def on_pause(self):
# allow the app to pause on android and ios
# set this to False if you do not want that.
return True
def on_resume(self):
pass
# is our app running as main or is it being imported as a module?
if __name__ == '__main__':
# our app is running as main
# let us instantiate the app and run it.
EventsApp().run()
Now run this APP.
python main.py
So this gives you just one simple blank window with nothing in there.
Keeping in mind the following items::
Saturday August 19: We will be sending out a mail to each volunteer group asking for their input on how they want to use the app. This should help us get a better idea of how to have the app designed.
Till that we will be starting with a basic app loads basic screens
Starting from the blank screen in step one,
The first thing that happens in our app should be the display of logo on splash screen.
Now what is a ScreenManager?
[ ] Your physical screen
[ ] Screen Manager
[1] [2] [3] Screens 1, 2 & 3
At any given point a screen manager would show you a one of the screens 1, 2 or 3.
This allows you to have many screens designed and available ready to be brought inside
the physical screen for display based on any event.
A ScreenManager is a Widget that houses multiple screens that can be loaded in it
using different types of transitions, for more info in the subjects please look at
https://kivy.org/docs/api-kivy.uix.screenmanager.html
What is a splash screen?
(Wiki) https://en.wikipedia.org/wiki/Splash_screen has a good explanation. Basically it is a Image + Logo, anything that gives the user a idea of what the product does. Some splash screens include versions some do not, look at the wiki for more details.
Now that every one knows what's a splash screen and a ScreenManager, let's make sure that
the root Widget of our app is a screen Manager.
https://github.com/pythonindia/PyCon-Mobile-App/blob/master/eventsapp/main.py#L38
The way we do this is to return ScreenManager widget's instance in the build method of the app class.
class EventsApp(App):
'''This is our entry point for the application
'''
def build(self):
from kivy.uix.screenmanager import ScreenManager
root = ScreenManager()
#return the root widget here
return root
Now What is a root widget?
Consider a Tree
0 This is our root
/ \
0 0
/ \ / \
0 0 0 0
A root widget in terms of the UI tree is the widget that sits at top of everything under it.
At any given time app.root points to one root widget by default this is the one returned by the build method.
Now that we understand what is a root widget, and that we
have ScreenManager as our current root of the app, we can
move forward to creating screens for this manager.
Let's first add a load_screen method in our main.py.
This method could be used/called by any place in our app
to load a screen in any given ScreenManager.
This method is supposed to be used like this::
app_instance.load_screen('ScreenName')
As a example look at this line
What does this function do?
A module_path has been setup before hand to be used by, load_screen('ScreenName') for loading the screens, in our case this is uix/screens.
So this method, load_screen looks for a module screenname.py in directory uix/screens/, under the directory where main.py resides and imports it.
Then this imports the class ScreenName from that file and instantiates it. Then this adds it to the screen manager instance.
ok, now that we have a method to load a screen in the ScreenManager, we need to create and load our LogoScreen or splash screen.
Let's create a new dir, uix under the eventsapp folder, add a blank __init__.py in it, so this folder can be imported as a module, then do the same for uix/screens folder adding a __init__.py under it..
cd PyCon-Mobile-App/eventsapp
mkdir uix
touch uix/__init__.py
mkdir uix/screens
touch uix/screens/__init__.py
Next let's create our splash screen.