0
我试图改变不同方法中按钮的属性。这是我目前正在使用:Kivy Python - 影响不同函数中的按钮
def _finish_init(self, dt):
self.ids.grid_1.cols = 5
def callfun(self, *args):
self.ChangePic()
# Creating a variable to use to determine if the buttons should be editable
binded = 0
# Loop to make 15 different buttons on screen
for x in range(15):
self.buttons.append(Button())
self.ids.grid_1.add_widget(self.buttons[x])
self.buttons[x].background_normal = 'YOUTUBE.png'
self.buttons[x].background_down = 'opacity.png'
self.buttons[x].bind(on_release=partial(self.HoldButtonNum, x))
# Make the button switch screens to input from calling the function above
if edit_mode is True:
self.buttons[x].bind(on_release=partial(self.SwitchScreenInput, x))
def ChangePic(self, *args):
_finish_init().buttons[1].background_normal = 'folder.png'
当ChangePic叫我的错误:
NameError: name '_finish_init' is not defined
有什么建议?
当使用self._finish_init(DT = 1).buttons [1] .background_normal = 'folder.png' 我我得到:“AttributeError:'NoneType'对象没有属性'按钮'” – John
'_finish_init()'函数返回'None'。看看这个函数,我没有看到任何返回语句。 – pypypy