ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-list
python-list
Clean PyQt selection comboBox
by Threader Slash other posts by this author
Nov 5 2009 1:39AM messages near this date
Re: list to table | Re: Clean PyQt selection comboBox
Hello Everybody, [image: 8)]

I am using Qt and need to build a selection comboBox -- e.g.:
http://www.java2s.com/Tutorial/VBImages/ComboBoxSelectionEventAddValue.PNG .

The problem is - after one choice was made, and the code run, for the next
time the user select a different choice, both, the present and all past
choices run. See what I mean: [image: ;(]

Code:

selected color - blue
we are on runBlue
selected color - red
we are on runBlue
we are on runRed


Here is the code:

.........................................
QtCore.QObject.connect(self.selectComboBox,
			QtCore.SIGNAL("currentIndexChanged(QString)"),
			self.combo_activateInput)
.........................................
def combo_activateInput(self):
        color=unicode(self.selectComboBox.currentText())
        if(color == "blue"):
            print "selected color - blue"
            QtCore.QObject.connect(self.okButton,
QtCore.SIGNAL("clicked()"), self.combo_runBlue)
        if(color == "red"):
            print "selected color - red"
            QtCore.QObject.connect(self.okButton,
QtCore.SIGNAL("clicked()"), self.combo_runRed)
        if(color == "yellow"):
            print "selected color - yellow"
            QtCore.QObject.connect(self.okButton,
QtCore.SIGNAL("clicked()"), self.combo_runYellow)
        del color
.........................................
def combo_runBlue(self):
        print "we are on runBlue"

def combo_runRed(self):
        print "we are on runRed"

def combo_runYellow(self):
        print "we are on runYellow"

I run "del color" to clean the content returned by
selectComboBox.currentText, but it didn't clean the content indeed.

So, any suggestion? All comments and suggestions are highly
appreciated. [image:
:D] [image: :D] [image: :D]
Thread:
Threader Slash
Mrab
Threader Slash

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved