-
Notifications
You must be signed in to change notification settings - Fork 26
Creating Your First App
Tyler Spadgenske edited this page May 13, 2015
·
1 revision
All TYOS apps use the same format. To create a TYOS app, you must use this format. Lets get started.
- In the home directory, switch the the apps directory of TYOS.
- Open the
order.txt
file and add the name of your app to the bottom. - Create a directory in the apps directory with the same name as the one in the order.txt file.
- Switch to your app's directory and add two files: app_name.png and app_name.py
- app_name.png is the icon used for your app. it must be 70x70 pixels.
- app_name.py is the main code for your app. It must have the following format:
#App Name
#MIT License
import pygame
class Run(): #The basis of all apps; the app object
def __init__(self, fona): #Must have fona argument, otherwise error will be returned
#Stuff to follow app protocol
self.exit = False #When value is changed to True, your app will exit back to the main menu
self.blit_one_surface = {'surface':[], 'rects':[]} #One surface in blit_one_surface will be blitted to all rects
self.blit = {'surfaces':[], 'rects':[]} #All surfaces in list will be blitted to their corresponding rect
self.next_app = None #The app that automatically runs after self.exit is True
def run_app(self): #The main function of your app. Everything goes in here.
pass
def get_events(self, event): #The event argument is a screen press. use event.pos to get location
pass
def on_first_run(self): #Runs once every time your app is opened unlike __init__ which only runs once every time TYOS is run
pass
The fona object can be used to communicate with the fona. Just use fona.transmit('AT command')