import time
import subprocess
from PyQt4 import QtGui, QtCore

.............
This function is not working!

@button.clicked.connect
   def connectClicked():
        button.setEnabled(False)
        process = subprocess.Popen("command", shell=True, stderr=subprocess.PIPE,        stdout=subprocess.PIPE)
       time.sleep(5) # 5 sek (?)
       button.setEnabled(True)

................

Recommended Answers

All 5 Replies

Error message or something like that?

Every time I clicked button and I want that the button is not activated for about 5 seconds, and each time I'm click the button again.

But when it works the first time (button is disabled).
Second time, button is not disabled and I can push it as much as I want.
Even every 1 seconds, but would need to be activated only after 5 seconds.
That could not be more pressing. Time is an arbitrary (1/2/3 or something seconds, with button is not activate, when i clicked this before)

I do not know it is done in QT, but in button handling method disable the button and start QT timer, which has handling function that enables the button again.

I do not know it is done in QT, but in button handling method disable the button and start QT timer, which has handling function that enables the button again.

I tried but you recommend a good tutorial?

I tried too so if my program is running (in subprocess), the button is inactive.
But this was not successful:-/

I can only give code in tkinter, but unfortunately it is very trivial code for tkinter:

from Tkinter import *

def button_push():
    print 'Button pushed'
    print 'Disabled for 5 s'
    button.config(state=DISABLED)
    button.after(5000, lambda:button.config(state=NORMAL))

root=Tk()
button=Button(text='Push me', command=button_push)
button.pack()
root.mainloop()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.