Python self.after不';传递值时不要等待

Python self.after不';传递值时不要等待,python,timer,self,pyserial,function,Python,Timer,Self,Pyserial,Function,我正在用python制作一个gui,它使用串行端口发送命令。在没有gui的旧脚本中,我在写入命令之间使用time.sleep(x)(to命令必须成功)。现在当我使用gui环境时,我不能使用sleep,所以我使用after 它运行良好,但: 我正在使用Tkinter作为我的gui。当我按下启动按钮时,OnButtonClickSTART在x时间后启动另一个功能。使用self.after在每个进程之间等待x秒。它可以工作,但是当我给函数赋值时,它不会等待给定的时间 def OnButtonCl

我正在用python制作一个gui,它使用串行端口发送命令。在没有gui的旧脚本中,我在写入命令之间使用time.sleep(x)(to命令必须成功)。现在当我使用gui环境时,我不能使用sleep,所以我使用after

它运行良好,但: 我正在使用Tkinter作为我的gui。当我按下启动按钮时,OnButtonClickSTART在x时间后启动另一个功能。使用self.after在每个进程之间等待x秒。它可以工作,但是当我给函数赋值时,它不会等待给定的时间

   def OnButtonClickSTART(self):
            print "START"
            self.button1.configure(state='disabled')
            self.after(1000, self.waitmore)

    def waitmore(self):
            value = 5
            print value
            self.after(10000,self.waitmuchmore(value))
    def waitmuchmore(self,value):
            print value
            self.after(10000,self.OnButtonClickSTOP)
    def OnButtonClickSTOP(self):
            print "STOP"
            self.button1.configure(state='normal')
这不是一种更好的方法来执行一系列命令,在它们之间留出一定的时间。与sleep类似,但使用1个功能,不禁用gui


Thx

使用
self.waitmuchmore(value)
将立即调用
waitmuchmore
方法。您需要使用或返回一个新函数,该函数将使用
调用
waitmuchmore
,并将其传递给
self。改为在
之后:

lambda: self.waitmuchmore(value)


似乎你在self.after中给出的时间有一个常数。
import functools
functools.partial(self.waitmuchmore, value)