我试着在kivy中调用一个关于按钮按下的函数,它位于不同于按钮所在的类屏幕中。我也尝试在app类中运行函数,但在那里遇到了问题。下面是我要调用的函数所在的类:
# Main screen with button layout
class LandingScreen(Screen):
def __init__(self, **kwargs):
super(LandingScreen, self).__init__(**kwargs)
self.buttons = [] # add references to all buttons here
Clock.schedule_once(self._finish_init)
def ChangePic(self):
self.buttons[1].background_normal = 'folder.png'
下面是我想用的按钮:
^{pr2}$为了从这个位置调用ChangePic(),我必须给ChangePic()加上什么前缀?在
或者-有没有一种方法可以从InputScreen类内部轻松处理LandingScreen类中的按钮?在
谢谢!在
您可以在应用程序类中创建变量:
然后在按钮中调用ChangePic(),如下所示:
^{pr2}$另外,这可以帮助您:StackOverflow,Kivy's Google Group,Introduction to properties
相关问题 更多 >
编程相关推荐