I'm working on some code to create a UI for a touchscreen in Python/Kivy. I'm new to both, and am having a bit of trouble with it. I'm getting an AttributeError raised on return PtWidg(), but the console isn't giving me anything super helpful to work off of:
Traceback (most recent call last):
File "/Users/revascharf/Documents/COLLEGE WORK/SENIOR YEAR/touchscreenInterface/touchUI.py", line 30, in <module>
ptApp().run()
File "/Applications/Kivy.app/Contents/Resources/kivy/kivy/app.py", line 802, in run
root = self.build()
File "/Users/revascharf/Documents/COLLEGE WORK/SENIOR YEAR/touchscreenInterface/touchUI.py", line 26, in build
return PtWidg()
File "/Applications/Kivy.app/Contents/Resources/kivy/kivy/uix/widget.py", line 320, in __init__
Builder.apply(self, ignored_consts=self._kwargs_applied_init)
File "/Applications/Kivy.app/Contents/Resources/kivy/kivy/lang.py", line 1970, in apply
self._apply_rule(widget, rule, rule, ignored_consts=ignored_consts)
File "/Applications/Kivy.app/Contents/Resources/kivy/kivy/lang.py", line 2044, in _apply_rule
cls = Factory_get(cname)
File "/Applications/Kivy.app/Contents/Resources/kivy/kivy/factory.py", line 130, in __getattr__
raise AttributeError
AttributeError
Process finished with exit code 1
This is my python file, touchUI.py:
import kivy
import datetime
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.button import Button
kivy.require('1.9.0')
from kivy.uix.image import Image
class SendButton(Button):
def on_press(self):
now = datetime.datetime.now()
self.text = 'minute is ' + str(now.minute)
class PtWidg(Widget):
pass
class ptApp(App):
def build(self):
return PtWidg()
if __name__ == '__main__':
ptApp().run()
And here is the contents of my .kv file, pt.kv:
#kivy 1.9.0
<sendButton>:
size: 40, 30
#pos: center_x + width / 4, center_y - height / 4
<PtWidg>:
Image:
center_x: root.width / 4
top: root.top - 50
source: 'SensoryWalkLogo.png'
height: db(50)
width: db(50)
sendButton:
center_x: root.width - root.width / 4
top: root.top - 50
text: 'Send minute to MSP430'
font_size: 40
Really, any tips or tricks would help me out a lot. Thank you!
Your code has these errors:
sendButton instead of SendButton in kv file.db(50) instead of dp(50). Using string '50dp' would be also a valid option.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With