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

Discussion in 'Python' started by raacampbell@gmail.com, Mar 18, 2007.

  1. Guest

    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!
     
    , Mar 18, 2007
    #1
    1. Advertising

  2. Guest


    > 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
     
    , Mar 18, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TXJEb3ROZXQ=?=

    Get List of Session IDs

    =?Utf-8?B?TXJEb3ROZXQ=?=, Dec 17, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    1,191
    Ross Overstreet
    Dec 19, 2004
  2. ulysses
    Replies:
    4
    Views:
    822
    Werner Schiendl
    Oct 22, 2003
  3. Replies:
    2
    Views:
    731
    Beat Bolli
    Jun 21, 2005
  4. daved170

    PyQT Qthread stuck main app

    daved170, Sep 15, 2009, in forum: Python
    Replies:
    0
    Views:
    443
    daved170
    Sep 15, 2009
  5. David Boddie

    Re: PyQT Qthread stuck main app

    David Boddie, Sep 15, 2009, in forum: Python
    Replies:
    2
    Views:
    415
    Dave Angel
    Sep 15, 2009
Loading...

Share This Page