Reputation: 723
I need to update a label in kivy with a global variable in python. How can I do that
The final result I need is to update the pos of canvas according to the switch interrupt.
global x1
def hi():
print "hi"
x1 = 20
print x1
class Mode1(Screen):
global x1
x1 = NumericProperty()
y1 = NumericProperty()
Buttonstatus = ''
ButtonPressed=''
def on_touch_move(self, touch):
print 'x1'
global x1
print x1
hi()
canvas.after:
Color:
rgb:[1, 0, 0,1]
Rectangle:
pos:root.x1,root.y1
size:20,20
Upvotes: 0
Views: 231
Reputation: 550
You already declared x1 as a global variable in your class. In your method try printing self.x1." print self.x1"
Upvotes: 1