【问题标题】:Kivy: Button binding in .py fileKivy:.py 文件中的按钮绑定
【发布时间】:2021-08-15 11:22:15
【问题描述】:

是否可以将参数(??argument??)传递给 python 文件中的方法? 示例:

class MyLayout(GridLayout): 
    def __init__ (self, **kwargs): 
        super().__init__(**kwrgs)
        self.button = Button(text= "b1")
        self.button.on_press = self.delete(??argument??) # <----- HERE

    def delete(self,argument):
        self.remove_widget(argument)

如果有,怎么做?

【问题讨论】:

    标签: button binding kivy


    【解决方案1】:

    您可以使用partial 方法:

    self.button.on_press = partial(self.delete, argument)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-12-05
      • 1970-01-01
      • 2018-11-11
      • 2014-06-01
      • 2016-02-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多