[Python] Kivy GUI with autobahn WAMP

Discussão em 'Python' iniciado por Stack, Julho 11, 2025.

  1. Stack

    Stack Membro Participativo

    And I am trying to combine between kivy application and autobahn wamp. For start I want to make the most basic app which will show a label and change it when a publish command will come.

    This is my basic kivy App:

    class MyFrontendComponent(App):

    def build(self):
    root = self.setup_gui()
    return root

    def setup_gui(self):

    self.label = Label(text='connecting...\n')
    self.layout = BoxLayout(orientation='vertical')
    self.layout.add_widget(self.label)
    return self.layout

    def changeLabel(self, text):
    self.label.text = text

    if __name__ == '__main__':
    # Run the kivy app
    kivyapp = MyFrontendComponent()
    kivyapp.run()


    And here is how autobahn Wamp should be implemented according to this guide

    from autobahn.twisted.wamp import ApplicationSession
    from twisted.internet.defer import inlineCallbacks


    class MyComponent(ApplicationSession):

    @inlineCallbacks
    def onJoin(self, details):
    print("session ready")

    def oncounter(count):
    print("event received: {0}", count)

    try:
    yield self.subscribe(oncounter, u'com.myapp.oncounter')
    print("subscribed to topic")
    except Exception as e:
    print("could not subscribe to topic: {0}".format(e))


    I have tried to use the autobahn.twisted.wamp Application using Threads because of the kivy app main loop but they are not getting syncronized

    from autobahn.twisted.wamp import Application

    app = Application()

    @app.signal('onjoined')
    def onjoined():
    kivyapp.changeLabel("realm joined!")


    Can you give a n advice of how to combine between them because I search a lot with no results.

    Continue reading...

Compartilhe esta Página