0
我想更改KV文件中按钮的背景颜色,但它不起作用。该按钮已定义并从Python文件中循环在Python中定义的KV文件上访问按钮
def gotoPost(i, instance):
print("HAHAHAH")
Manager.current = 'ScreenTwo'
class ScreenOne(Screen):
box = ObjectProperty(None)
def on_box(self, *args):
for i in range(5):
btn = Button(text=str(i))
btn.bind(on_press=partial(gotoPost,i))
self.box.add_widget(btn)
Factory.register('ScreenOne', cls=ScreenOne)
class ScreenTwo(Screen):
pass
class Manager(ScreenManager):
screen_one = ObjectProperty(None)
screen_two = ObjectProperty(None)
class MainApp(App):
def build(self):
return Manager()
if __name__=="__main__":
MainApp().run()
如何访问KV文件中的按钮?
问题是“我如何访问KV文件中的按钮?”而不是在Python脚本中。 – ikolim