Stuck with pyqt: can't get/read button IDs from a qbuttongroup

R

raacampbell

Hi,

I'm learning Python and QT and have set myself the task of writing a
simple calculator applet. I'm using Qt3 and with the designer have
made a button group which contains 10 buttons to allow the user to
press the digits 0 to 9.

The idea is that the button group is associated with a single slot.
When I click a button the qbuttongroup sends a signal to a slot I've
named getNumber. At the moment I just want this to read buttonGroupid
of the clciked button and write this to the screen (the buttonGroupid
is equal to the value the user wishes to select). So if the user
clicks on, say, button "7" then this digit will be printed to the
listbox. Problem is that I can't work out how to read this ID. I can't
believe it's this hard--I have RTFM, some programing experience, and
have searched google for 3 days. No joy.

The best I've managed so far is this line from the .ui.h file
void calc::getNumber(int id)
{
self.listBox1.insertItem(str(id))
}

which translates to this in the .py:
def getNumber(self,a0):
self.listBox1.insertItem(str(id))


All that does is is print the text "<built-in function id>" to my list
box.

What am I missing?

Thanks!
 
R

raacampbell

which translates to this in the .py:
def getNumber(self,a0):
self.listBox1.insertItem(str(id))

As is typically the way with these things, I've just solved it. I
changed the text in the file generated by pyui. It now reads:

def getNumber(self,a0):
self.listBox1.insertItem(a0)


I suppose my question now becomes whether or not editing the .py file
in this manner is good thing to be doing. What references do people
recomend I consult with regard to this sort of thing?

Thanks,
Rob
 

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

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top