[PyKDE] Python list handling for QRect, QPoint, and QSize

Phil Thompson phil at river-bank.demon.co.uk
Mon Nov 4 21:48:00 GMT 2002


On Monday 04 November 2002 7:38 pm, Hans-Peter Jansen wrote:
> On Monday 04 November 2002 19:57, Phil Thompson wrote:
> > On Monday 04 November 2002 6:36 pm, Hans-Peter Jansen wrote:
> > > Hi Phil,
> > >
> > > since I catched the flu this weekend, I think of contributing something
> > > useful to PyQt. Namely the IMHO missing handling of python lists, where
> > > QRect, QPoint, and QSize objects are expected. (QColor?)
> >
> > I'm not sure I understand. Are you saying that you want to pass a list of
> > (say) x and y coordinates wherever a QPoint was expected? (Wouldn't a
> > tuple be better?)
>
> Exactly. Why not support both.
>
> Imagine a typical situation: restore position and size of an app:
> (tuple or list doesn't matter much here)
>
>         wh = self.cfg.mainScreenSize
>         if wh:
>             self.resize(wh[0], wh[1])
>         xy = self.cfg.mainScreenLocation
>         if xy:
>             self.move(xy[0], xy[1])
>
> would then read:
>
>         if self.cfg.mainScreenSize:
>             self.resize(self.cfg.mainScreenSize)
>         if self.cfg.mainScreenLocation:
>             self.move(self.cfg.mainScreenLocation)
>
> Do you like this idea?

Yes and no. See item 18 of the TODO file in the sip tarball, which I haven't 
come to a conclusion about yet.

At the moment the only way to implement anything like this is to add more 
resize(), move() (etc, etc) overloads that use handwritten %MemberCode. Not 
something I'd advise doing.

Phil




More information about the PyQt mailing list