Created
July 16, 2013 10:54
-
-
Save jegger/6007722 to your computer and use it in GitHub Desktop.
Infinitive loop with dbus and kivy (logging)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kivy.app import App | |
from kivy.uix.button import Button | |
from kivy.uix.widget import Widget | |
import dbus.service | |
from dbus.mainloop.glib import DBusGMainLoop | |
class UI(Widget): | |
def __init__(self, **kwargs): | |
super(UI, self).__init__(**kwargs) | |
#Add check button | |
button=Button(text='Lets Crash!') | |
button.bind(on_press=self.check_dbus) | |
self.add_widget(button) | |
def check_dbus(self, *kwargs): | |
'''Call do_math on kivy1 | |
''' | |
self.bus = dbus.SessionBus() | |
server = self.bus.get_object('org.test.kivy1', '/kivy1') | |
server.do_math(2, dbus_interface = 'org.test.kivy1') | |
class Client(App): | |
def build(self): | |
return UI() | |
if __name__ == '__main__': | |
Client().run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kivy.app import App | |
from kivy.uix.widget import Widget | |
#from kivy.support import install_gobject_iteration | |
import dbus.service | |
from dbus.mainloop.glib import DBusGMainLoop | |
class DBusServer(dbus.service.Object): | |
def __init__(self): | |
bus_name = dbus.service.BusName('org.test.kivy1', bus=dbus.SessionBus()) | |
dbus.service.Object.__init__(self, bus_name, '/kivy1') | |
@dbus.service.method('org.test.kivy1') | |
def do_math(self, number): | |
return | |
DBusGMainLoop(set_as_default=True) | |
class Client(App): | |
def build(self): | |
#Do not call install_gobject_iteration() => Otherwise it won't fail! | |
#install_gobject_iteration() | |
dbs = DBusServer() | |
return Widget() | |
if __name__ == '__main__': | |
Client().run() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment