Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'attribute': 0.07; 'skip:p 60': 0.07; 'string': 0.09; 'main()': 0.09; 'skip:# 30': 0.09; 'skip:# 60': 0.09; 'val': 0.09; '"%s"': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'key)': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'need:': 0.16; 'skip:p 90': 0.16; 'skip:q 30': 0.16; 'subject:object': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'print': 0.22; 'header:User-Agent:1': 0.23; 'code:': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; "i'm": 0.30; 'code': 0.31; "skip:' 10": 0.31; 'file': 0.32; 'another': 0.32; '(most': 0.33; 'subject:from': 0.34; 'skip:u 20': 0.35; 'but': 0.35; 'skip:" 50': 0.36; 'to:addr:python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'numbers': 0.61; 'dear': 0.65; 'header:Reply-To:1': 0.67; 'caused': 0.69; 'reply-to:no real name:2**0': 0.71; 'dict.': 0.84; 'reply-to:addr:python.org': 0.84; 'subject:add': 0.91 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=bKAvfpOZ c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=05MOGALpfCEA:10 a=f4ofmB8XsgoA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=BBIqEB8VFQEA:10 a=NAKoxRX8rWHRNpg-G3QA:9 a=wPNLvfGTeEIA:10 X-AUTH: mrabarnett:2500 Date: Thu, 17 Oct 2013 01:43:03 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: how to add object from dict References: <1381961694.21908.13.camel@debian> In-Reply-To: <1381961694.21908.13.camel@debian> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 55 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1381970583 news.xs4all.nl 15915 [2001:888:2000:d::a6]:48600 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:56918 On 16/10/2013 23:14, Mohsen Pahlevanzadeh wrote: > Dear all, > > I have the following code in projects.py: > ##################################################33 > for row in xrange(len(uniqueFields)): > instance = QtGui.QCheckBox(uniqueFields[row]) > > projectsFindInstance.projectsInstance.addOnFieldsInstance.update({"%s" % > uniqueFields[row]:instance}) > > projectsFindInstance.tableWidget.setCellWidget(row,0,instance) > > projectsFindInstance.tableWidget.setRowCount(projectsFindInstance.tableWidget.rowCount()+1) > ############################################################### > > about code caused i fill up a QTableWidget from QChekBox, and i store > string of QCheckBox and its Object in dict. > > and another file,(projectsFind.py) i have the following code: > #################################################################3 > for key, val in > self.projectsInstance.addOnFieldsInstance.items(): > instance = getattr(self,"%s" % val) > print val > #QtCore.QObject.connect(instance, > QtCore.SIGNAL(_fromUtf8("stateChanged (int)")), > #lambda: > self.projectsInstance.setFilterDict_Find("TWCH",self,"addonfields",instance.CheckState(),instance)) > ######################################################################3 > I want to generate connect function accroding to numbers of obbjects. > But i get the following traceback: > > ################################################################3 > Traceback (most recent call last): > File "./main.py", line 117, in > main() > File "./main.py", line 104, in main > x.showFindProjects() > File "/home/mohsen/codes/amlak/amlak/src/UIInterface.py", line 101, in > showFindProjects > self.uiProjectsFind.setupUi(self.projectsFind) > File "/home/mohsen/codes/amlak/amlak/src/projectsFind.py", line 271, > in setupUi > instance = getattr(self,"%s" % val) > AttributeError: 'Ui_ProjectsFind' object has no attribute > '' > ############################################################# > > Help needed...... > I'm guessing, but perhaps you need: instance = getattr(self, "%s" % key)