473,395 Members | 1,458 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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

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 '07 #1
1 2223

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 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

35
by: Vamsi Mudrageda | last post by:
I am kind of new to Python, and after trying and using wxPython, I found it kind of lacking in easy-to-read documentation, speed at loading, and GUI response-time. So I am looking for an another...
8
by: simo | last post by:
OK, so I'm at the stage where I want to make a choice between wxPython and PyQt. Currently I'm using wxPython mainly due to the fact that it has GPL Linux and Windows versions. I prefer Qt to...
2
by: Sibylle Koczian | last post by:
Still trying to learn PyQt from a book about several Python GUI toolkits, I seem to learn first what doesn't work. The following small script seems to work, but after closing the window I get the...
1
by: Chump Wad | last post by:
I will now die. I am too ignorant to make it work. 10.2.setEventCB.py segfaults for me. It is almost there, but it is not there. SoQt.init returns a string, which I can't use as the parent...
17
by: eholbroo | last post by:
I've narrowed down my toolkit selection for my project to wxPython and pyQt, and now i'd like to hear any opinions, war stories, peeves, etc, about them, particularly from anyone who's used...
4
by: Gabriel - BR | last post by:
Hi,,, Is possible disable the close button in KDE management window? Using python+qt? thanks
9
by: anders | last post by:
I am writing a plugin for a piece of software in python, and I want to start up a PyQt GUI in the plugin, without stalling the main thread while the gui is running (later i will want to pass...
3
by: Marcpp | last post by:
Hi, I'm introducing to program in python + pyqt. I have a main window that call a second window (to introduce a info with textedit) when press the second window button I need to return to the main...
1
by: Alexander Eisenhuth | last post by:
Hello alltogether, My System: Python 2.5.1 Boost.Python Qt 4.2.2 SIP 4.6 PyQt 4.2 WinXp
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.