Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #56918 > unrolled thread
| Started by | MRAB <python@mrabarnett.plus.com> |
|---|---|
| First post | 2013-10-17 01:43 +0100 |
| Last post | 2013-10-17 01:43 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: how to add object from dict MRAB <python@mrabarnett.plus.com> - 2013-10-17 01:43 +0100
| From | MRAB <python@mrabarnett.plus.com> |
|---|---|
| Date | 2013-10-17 01:43 +0100 |
| Subject | Re: how to add object from dict |
| Message-ID | <mailman.1133.1381970583.18130.python-list@python.org> |
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 <module>
> 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
> '<PyQt4.QtGui.QCheckBox object at 0xa4abd64>'
> #############################################################
>
> Help needed......
>
I'm guessing, but perhaps you need:
instance = getattr(self, "%s" % key)
Back to top | Article view | comp.lang.python
csiph-web