LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-18-2009, 12:09 AM   #1
threaderslash
Member
 
Registered: Dec 2008
Location: HongKong
Distribution: Fedora/Centos/RedHat
Posts: 115

Rep: Reputation: 15
Qt Python radiobutton: activate event


Hi Everybody,

I am developing a project for one customer, where the design has a radio button with exclusive options.

Here is a piece of the code that runs and show two nice radio buttons:
Code:
self.performGroupBox = QtGui.QGroupBox(self.centralwidget)
self.performGroupBox.setGeometry(QtCore.QRect(50, 20, 181, 121))
self.performGroupBox.setObjectName("performGroupBox")     
        
self.consultRadioButton = QtGui.QRadioButton(self.performGroupBox)
self.consultRadioButton.setGeometry(QtCore.QRect(40, 30, 84, 18))
self.consultRadioButton.setObjectName("consultRadioButton")

self.insertRadioButton = QtGui.QRadioButton(self.performGroupBox)
self.insertRadioButton.setGeometry(QtCore.QRect(40, 60, 84, 18))
self.insertRadioButton.setObjectName("insertRadioButton")
it just looks like:
Code:
perform:
        () Consult
        () Insert
The point here is, how to know what choice was marked: "consultRadioButton" or "insertRadioButton"?

Here is a sample on trying to get this information:
Code:
if self.consultRadioButton.isChecked():
            self.call_Consult()
if self.insertRadioButton.isChecked():
            self.call_Insert()
But it didn't do anything when the radiobutton is chosen.

Otherwise, using connect should be another option:
Code:
QtCore.QObject.connect(self.consultRadioButton, QtCore.SIGNAL("currentIndexChanged(QString)"), self.call_Consult)  
QtCore.QObject.connect(self.insertRadioButton, QtCore.SIGNAL("currentIndexChanged(QString)"), self.call_Insert)
But it didn't work either.

What is missing here... Any suggestion?

All comments are highly welcome and appreciated.
 
Old 11-18-2009, 09:54 PM   #2
threaderslash
Member
 
Registered: Dec 2008
Location: HongKong
Distribution: Fedora/Centos/RedHat
Posts: 115

Original Poster
Rep: Reputation: 15
Hi Guys,

I am still trying to get the choice made by the user on Python Qt with radiobutton. Here is some changes on signal I did:

Code:
QtCore.QObject.connect(self.radioButton1, QtCore.SIGNAL("toggled()"),self.radio_activateInput)
QtCore.QObject.connect(self.radioButton2, QtCore.SIGNAL("toggled()"),self.radio_activateInput)
and that

Code:
QtCore.QObject.connect(self.performGroupBox, QtCore.SIGNAL("toggled()"),self.radio_activateInput)
But it didn't make anything when I click on the option.

Yes, I have enabled it:

Code:
self.radioButton1.setCheckable(True)
self.radioButton1.setChecked(True)
self.radioButton2.setCheckable(True)
Any suggestion?
 
Old 11-19-2009, 12:11 AM   #3
threaderslash
Member
 
Registered: Dec 2008
Location: HongKong
Distribution: Fedora/Centos/RedHat
Posts: 115

Original Poster
Rep: Reputation: 15
Lightbulb solved

Here is solution... now working:
Code:
QtCore.QObject.connect(self.radioButton1,QtCore.SIGNAL("toggled(bool)"),self.radio_activateInput)
when have the parameter bool included into toggled to signal, it worked.
 
  


Reply

Tags
member


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Python Python Python (aka Python 3) LXer Syndicated Linux News 0 08-05-2009 08:30 PM
I can't activate (i'mean activate) my wireless card Mardrus Linux - Newbie 5 05-04-2008 06:35 AM
Fire Event from other event in Visual C++ Express Edition chrisliando Programming 1 11-08-2007 05:12 PM
I need a python code that activate a button Linh Programming 0 08-20-2004 10:47 AM
Cannot activate Javascript within Python script Linh Programming 0 09-22-2003 11:51 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration