我想更改我的KV文件中按钮的背景色,但它不起作用。按钮是从Python文件定义和循环的
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文件中的按钮
您可以指定一个按钮,在按下时根据需要更改颜色。例如:self.color或self.back_color=(7,0,1,1)。。。我想那是红色的
相关问题 更多 >
编程相关推荐