我有三个按钮。单击时的每个按钮都会向端口 58888 发送一个命令,该端口有一些工作,一旦工作完成,基本上该特定按钮应在 5 分钟后再次按下。
知道如何阻止按钮吗?所以有人不能在那个按钮上产生洪水一段时间?
button = gtk.Button("a")
button.connect("clicked" , self.on_the_fly("a") , None)
bbox.add(button)
button = gtk.Button("v")
button.connect("clicked" , self.on_the_fly("v") , None)
bbox.add(button)
button = gtk.Button("b")
button.connect("clicked" , self.on_the_fly("b") , None)
bbox.add(button)
按钮使用的方法:
def on_the_fly(self, input):
logging.debug( 'Clicked at x={0}, y={0}' )
try:
if self.myname.startswith("enduser"):
logging.debug("reconnect")
else:
if input.startswith("a"):
command = "r0x01"
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect(("localhost", 58888))
client_socket.send(command)
client_socket.close()
elif input.startswith("v"):
command = "r0x02"
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect(("localhost", 58888))
client_socket.send(command)
client_socket.close()
elif input.startswith("both"):
command = "r0x03"
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect(("localhost", 58888))
client_socket.send(command)
client_socket.close()
else:
print "nothing"
subprocess.Popen(["/var/tmp/runme.sh"], stdout=subprocess.PIPE)
except Exception, err:
logging.debug( err )
pass