From 71a5d04fe19749427c647a4ced583efdcb0ee3b8 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Mon, 19 Mar 2012 11:07:14 +0100 Subject: [PATCH] pep8 fixes --- examples/frameworks/twisted/twistd_app.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/examples/frameworks/twisted/twistd_app.py b/examples/frameworks/twisted/twistd_app.py index 77415167b4..cfd9f2a92f 100644 --- a/examples/frameworks/twisted/twistd_app.py +++ b/examples/frameworks/twisted/twistd_app.py @@ -1,11 +1,11 @@ from kivy.support import install_twisted_reactor install_twisted_reactor() -import os, sys +import os +import sys from kivy.app import App from kivy.uix.gridlayout import GridLayout -from kivy.uix.button import Button from kivy.properties import BooleanProperty from kivy.lang import Builder @@ -14,17 +14,21 @@ TWISTD = 'twistd web -p 8087' + class AndroidApplicationRunner(UnixApplicationRunner): + def run(self): + self.preApplication() self.application = self.createOrGetApplication() - self.logger.start(self.application) + self.logger.start(self.application) sc = IServiceCollection(self.application) # reactor is already running, so we just start the service collection sc.startService() return self.application + Builder.load_string(''' : cols: 1 @@ -33,9 +37,13 @@ def run(self): on_release: root.cb_twistd() ''') + class TwistedTwistd(GridLayout): + running = BooleanProperty(False) - def cb_twistd(self,*la): + + def cb_twistd(self, *la): + if self.running: IServiceCollection(self.app).stopService() self.running = False @@ -48,9 +56,12 @@ def cb_twistd(self,*la): self.app = AndroidApplicationRunner(config).run() self.running = True + class TwistedTwistdApp(App): + def build(self): return TwistedTwistd() - + + if __name__ == '__main__': TwistedTwistdApp().run()