ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Using ROS message and python to update text input field in kivy GUI

asked 2014-06-25 04:41:21 -0500

Hozer gravatar image

updated 2014-06-25 04:45:02 -0500

I try to design a GUI to handle stepper motors via ROS, kivy and python. You can find a minimal version of the GUI below. Actually I want to use a ROS message to update a kivy text input field (read only). In the minimal example, pressing the button should transfer the data of the first input field over a local ROS node to the second input field. Actually it seems, that the Callback within the rospy.Subscriber() doesn't enter the Test class.

Thank You for any suggestions!

import kivy

import rospy
from std_msgs.msg import String

from import App
from kivy.core.window import Window
from kivy.uix.widget import Widget
from kivy.uix.boxlayout import BoxLayout

class Test(BoxLayout):
    text_is = 'text before button press'

    def Pub(self):
        publish = self.ids.test_text_pub.text
        except rospy.ROSInterruptException: pass

class ROSNode(Widget):

    def Callback(publish):
        print( #check if Callback has been called
        test.text_is =

    new_text_is = rospy.Publisher('new_text_is', String, queue_size=10)
    rospy.Subscriber('new_text_is', String, Callback)

    rospy.init_node('talker', anonymous=True)

class TestApp(App):

    def build(self):
        return Test()

if __name__ == '__main__':


#:kivy 1.0

        orientation: 'vertical'

            id: test_button
            text: 'publish'
            on_press: root.Pub()

            id: test_text_pub
            text: 'text after button press'

            id: test_text_sub
            text: root.text_is
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-01-16 03:23:23 -0500

Pototo gravatar image


You can use this file as an example to help you:

edit flag offensive delete link more

Question Tools


Asked: 2014-06-25 04:41:21 -0500

Seen: 2,287 times

Last updated: Jan 16 '16