我正在尝试更改其他方法内部按钮的属性。这就是我目前使用的:
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'未定义
有什么建议吗?
答案 0 :(得分:0)
看起来这两个函数都是类的成员,您需要使用
self._finish_init()...