Kivy Python影响不同函数中的按钮

2024-09-24 22:27:42 发布

您现在位置: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

有什么建议吗


Tags: thetoselfidsifpnginiton