Kivy Python - 影响不同功能内的按钮

时间:2017-07-20 01:22:45

标签: python kivy

我正在尝试更改其他方法内部按钮的属性。这就是我目前使用的:

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'未定义

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

看起来这两个函数都是类的成员,您需要使用

self._finish_init()...