how to query/test the state of a qt widget?

R

raacampbell

Hi,

I'm writing a simple Python/Qt3 application and I am trying to write
some code in which the user presses a button and the program performs
action A or B depending upon the state of a pair of radio buttons. I
would therefore like Python to read the state of the buttons. I was
expecting this to be straightforward but I've not been able to work
out how to do it and searching on Google hasn't helped. Surely there's
a one-liner that will do what I want? It seems like an every-day sort
of problem. I'm after something like:

if self.polPlotRadioButton.enabled==1: print "BLAH"

I've found squish from www.froglogic.com but that seems over the top.
Possibly pythonqt.sourceforge.net has something that will solve my
problem but that wants Qt4 and at the moment I'm making heavy use of
matplotlib widgets and I've not worked out how to get them to
incorporate into a Qt4 app so I'm stuck with Qt3.

Anyone know the answer?

Thanks in advance!
 
D

Diez B. Roggisch

Hi,

I'm writing a simple Python/Qt3 application and I am trying to write
some code in which the user presses a button and the program performs
action A or B depending upon the state of a pair of radio buttons. I
would therefore like Python to read the state of the buttons. I was
expecting this to be straightforward but I've not been able to work
out how to do it and searching on Google hasn't helped. Surely there's
a one-liner that will do what I want? It seems like an every-day sort
of problem. I'm after something like:

if self.polPlotRadioButton.enabled==1: print "BLAH"

I've found squish from www.froglogic.com but that seems over the top.
Possibly pythonqt.sourceforge.net has something that will solve my
problem but that wants Qt4 and at the moment I'm making heavy use of
matplotlib widgets and I've not worked out how to get them to
incorporate into a Qt4 app so I'm stuck with Qt3.

Anyone know the answer?

RTFM. The Qt-docs are extensive. And the QRadioButton-docs are pretty
straight forward:

http://doc.trolltech.com/3.3/qradiobutton.html#checked-prop



So your code above should be

if self.polPlotRadioButton.isChecked(): print "blah"

Diez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,781
Messages
2,569,619
Members
45,314
Latest member
HugoKeogh

Latest Threads

Top