[PyQt] List of instances of a class

Chris O'Halloran cmoman at gmail.com
Wed Oct 29 09:38:01 GMT 2014


>
> > At this stage though, I'd like to be able to return the 'handle' (I'm new
> > to a lot of this') of when I originally instantiated the class eg
> self.Rf.
> > self.diallist[0].objectname() only return what you assign it and not the
> > handle.
>
> I don't follow. Looking at the output above, you get a reference to
> the instance of your class, i.e. to the same thing self.Rf etc. would
> be.
>

I can see myself expanding the number of gui objects which then need to be
laid out.  By creating list of gui object I could then use a loop to lay
them out

>
> > I've been searching through Object.metaclass() but am not
> > convinced I'm looking in the right place. self.dialist[0].__getAttr__()
> > seems to want a parameter but I'm not sure what to give it.
>
> You probably don't want to deal with Qt metaclasses, and you don't
> want to call __getattr__ by hand. If anything, you'd use
> getattr(self, name).
>
> But either way, that sounds like an overcomplicated way. I suggest
> either keeping a dict of all objects:
>
> Thanks for the suggestion


> But let's take another step back and look at the big picture. Why do
> you want a list of all dials? What are you going to do with them?
> What is the repetitive code you want to get rid of?
>

Dynamically generating the layout was the thinking behind this.

>
> Maybe what you really should do is using Qt's signal/slot system, add
> some signal, and connect all dial's slots to it, and then forget about
> your dials
>
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20141029/5b3103c9/attachment.html>


More information about the PyQt mailing list