from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.button import Button
from kivy.properties import NumericProperty, ReferenceListProperty, ObjectProperty
from kivy.clock import Clock
from colorsys import hsv_to_rgb, rgb_to_hsv
from kivy.uix.gridlayout import GridLayout
class MoneyControl(Widget):
cartel = ObjectProperty(None)
lay = 3
rainbow = [0.0,1.0,1.0,1.0]
def hsva_to_rgba(self, hsva):
rgba = hsv_to_rgb(hsva[0], hsva[1], hsva[2])
rgba = list(rgba)
rgba.append(hsva[3])
return rgba
def update(self, dt):
self.lay += 1
self.cartel.text = str(self.lay)
self.rainbow[0] += self.lay*0.0001
finalRgba = self.hsva_to_rgba(self.rainbow)
self.cartel.color = finalRgba
class MoneyControlApp(App):
def build(self):
prog = MoneyControl()
Clock.schedule_interval(prog.update, 1.0 / 60.0)
return prog
if __name__ == '__main__':
MoneyControlApp().run()
#:kivy 1.0.9
<MoneyControl@Widget>: #This works. Comment this line...
#MoneyControl:#RootWidget # ... and uncomment this one. It stops working.
cartel: crt
Label:
id: crt
font_size: 20
center_x: root.width * 0.5
top: root.height * 0.5
text: "hola"
color: 1, .3, .8, 1
from kivy.lang import Builder
money_control = Builder.load_file(moneyapp.kv)
With an instance to be the root widget, an error arises about the line "self.cartel.text = str(self.lay)"
It says:
AttributeError: 'Nonetype' object has no attribute 'text'
I'm using Kivy v1.9.0 on Geany in Ubuntu, for if that helps...
It work to you?, The same code in you computer, nevermind which line gets commented?