按下按钮时出现问题:我总是得到下面的错误。谁能建议我如何解决这个问题?
主.py文件:
class MainApp(MDApp):
def build(self):
self.dati = Builder.load_file("conf.kv")
return Builder.load_file("conf.kv")
def show_data(self):
print(self.boxlay.btn_nav.scr1.classe.text)
MainApp().run()
conf.kv 文件:
BoxLayout:
orientation:'vertical'
id: boxlay
btn_nav:btn_nav
MDToolbar:
title: 'Bottom navigation'
MDBottomNavigation:
id: btn_nav
scr1:scr1
MDBottomNavigationItem:
id: scr1
classe:classe
name: 'screen 1'
text: 'Python'
icon: 'language-python'
MDTextField:
id: classe
hint_text: "Enter Class"
pos_hint:{'center_x': 0.5, 'center_y': 0.5}
size_hint_x:None
width:300
MDRectangleFlatButton:
text: 'Python'
pos_hint: {'center_x': 0.5, 'center_y': 0.4}
on_release: app.show_data()
运行此代码我收到的错误是:
on_release: app.show_data()
File "main.py", line 27, in show_data
print( AttributeError: 'NoneType' object has no attribute 'btn_nav')
AttributeError: 'BoxLayout' object has no attribute 'classe'
感谢您的帮助
慕少森
相关分类