PDA

View Full Version : pyQT how do I enable or disable a pushbutton from the main code?



Michael Druckenmiller Sr
12th January 2012, 16:58
I have a form from which I can launch various Test Modules.

The Form has 16 PushButtons, one for each of the possible Modules.

I need to disable Button_2 through Button_11 until the Modules that are connected to Button_1 and Button_0 are succesfully completed.

The Buttons are on a pyQT mainwindow, tabbed form which is referenced by a class titled, "tcmainform".

tcmainform is in turn instansiated? as simply, "form"

Again, what I want to do is disable/enabled buttons in the main code stream.

Is there a way to do it.


Thanks!
Mike Sr.

Michael Druckenmiller Sr
12th January 2012, 19:44
This code works for a range of "Button_xx"


Selection=[]
for i in range(16):
Selection.append(getattr(tcDict.get("form"), "Button_%d" %(i+1)))
Selection[i].setEnabled(False)

What had me "stumped" was I forgot that the QT calls are "Functions" to which you "pass" a parameter not "set" a parameter.

that is: Selection[i].setEnabled = False will not work

My VB6 days getting in the way... :)