【问题标题】:In kivy, how to get the duration of a button click在kivy中,如何获取按钮单击的持续时间
【发布时间】:2020-07-30 14:40:08
【问题描述】:

我需要根据用户单击按钮的秒数执行操作。

def add_day(self,ins):
        for i in range(<click Time>):
               cur=datetime.datetime.strptime(self.date_lb.text,'%d %b %Y').date()
               dt=cur+day
               self.date_lb.text=dt.strftime('%d %b %Y')

这里我把日期加一 提前致谢!

【问题讨论】:

    标签: python user-interface button kivy


    【解决方案1】:

    您可以对Buttonon_press 事件使用回调方法,将按下时间记录到变量中。
    然后可以对同一个Buttonon_release事件使用另一种回调方法,获取释放时间,并从之前的变量中减去。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-10-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-26
      • 2020-09-01
      • 1970-01-01
      相关资源
      最近更新 更多