How do we dynamically change the text in label widget of Tkinter according to the change of subscribed topic message?

asked 2016-05-10 14:40:24 -0500

Ros User gravatar image

updated 2016-05-10 14:43:17 -0500

I wanted to change the text of my label according to the topic message to which my node subscribes. But the problem is that the text in the label is not changing with the change of topic message. A portion of my code is given below:(I used the code to dynamically change the text in the label from )

    v = StringVar()
    self.clock = Label(frame, font=('times', 20, 'bold'), bg='green', textvariable = v)
    self.clock.pack(fill=BOTH, expand=1)
    rate = rospy.Rate(2)

    while not rospy.is_shutdown():
        rospy.Subscriber("distance", Float32, self.callback)
        print("distance = %f", distance)
edit retag flag offensive close merge delete