App template with plugins for python 3. Beta-version
License:GNU/GPL v3.0
This app is fully extendable and allows to use components and plugins.
*Component is that part of app that could be used as well by app and plugins(e.g. button)
All plugins are work in multithreading and could use all of app parts,such as logging,exception handling and others.
The simpiest way is to create main function and start app with it.
So main class of this template is App
To initiallize it you need:
logfilename--name of file where log will be stored
main_function--function that will be runned with app,called with params:parent(app class)
Non-required params:
init_function--function called after all app initiallized(params same with main_function)
on_exception--function called if exception occurs(params e-- Exception class)
Example:
from App import App
import config
import time #We need sleep from here
def main(parent): #main function will be runned with app as parent of
config.log.log("Hello,World!!!") #logging message to logfile
cycles=0 #counter of cycles(after 5 we'll stop)
while parent.running:
cycles=cycles+1
time.sleep(1) #pretending that we're doing something important
if cycles>5: #we're done with our task,so
parent.event("$APP_QUIT")#quitting app you could also try using parent.running=False(but I didn't check,and if you're using plugins it is strongly unrecommended.
if __name__=="__main__":
app=App("app.log",main_function,"Example1") #creating our app
app.run()#and running it