What is equivalent to root.update() of tkinter in Kivy? Tks

44 views
Skip to first unread message

alam....@gmail.com

unread,
Feb 4, 2017, 12:36:25 AM2/4/17
to Kivy users support
Dear Friends

I want to draw x, y coordinates of line with the data from serial port. However, the coordinates are available but there is no update on the GUI (graphics). How to update it similar to <root.update()> tkinter?

Thanks


File: sample.kv 
***************************************************************************
<MyScreenManager>:

Home:
name: 'Home'
<Home>:
name: 'Home'
BoxLayout:
orientation: 'vertical'

BoxLayout: 
size_hint_y: 50
orientation: 'horizontal'
Button: 
id: road
text: 'Plot'
font_size: 25
background_color: 0,0,1,1
on_release: app.root.plot()

BoxLayout:
size_hint_y: 1000
orientation: 'horizontal'

BoxLayout:
size_hint: 0.9, 1
orientation: 'horizontal'
Widget:
id: my_can5
x0: self.width*.02
y0: self.height/3
my_clr: 0,1,0,1
mi_pts: 875, 0, 200, 0
canvas:
Color:
rgba: self.my_clr
Line:
points: self.mi_pts
width: 3

***************************************************************************
***************************************************************************

File: sample.py
***************************************************************************
class MyScreenManager(ScreenManager):

    def plot(self):
        print "In"
        i = 1
        x0 = 875
        y0 = 900
        x1 = 550
        y1 = 925
        inVoltS = serial.Serial('/dev/tty.usbmodem1411', 9600)
        while i > 0:
            inVoltR = float(inVoltS.readline()) # Read the newest output from the Arduino         
            inVolt = inVoltR * 100
            print "Yes", inVolt
            x1 = x1 + 1
            y1 = y1 + inVolt
            newPoint = self.get_screen('Home').ids.my_can5.mi_pts = (x0,y0,x1,y1)
            print newPoint
            x0 = x1
            y0 = y1
            sleep(1)
            i = i + 1

#***************** APP OBJECT ***********************
class zAmpleApp(App):

    def build(self):
        return MyScreenManager()

if __name__ == '__main__':
    zAmpleApp().run()

Ivan Acevedo

unread,
Feb 4, 2017, 6:12:34 AM2/4/17
to Kivy users support
Do not use a "while" to create an infinite loop, the application will block, use:
Clock.schedule_interval()

Hilaal Alam

unread,
Feb 4, 2017, 7:40:56 AM2/4/17
to kivy-...@googlegroups.com
Thank you Ivan. I will try


On 4 Feb 2017, at 7:12 PM, Ivan Acevedo <ivanla...@gmail.com> wrote:

Do not use a "while" to create an infinite loop, the application will block, use:
Clock.schedule_interval()

--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/Bno4OZOEtg8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages