[PyQt] PyQt-based Tetr*s

Joshua Bronson jabronson at gmail.com
Wed Mar 26 20:05:39 GMT 2008


On Tue, Mar 25, 2008 at 7:50 PM, Matt Newell <newellm at blur.com> wrote:

> On Tuesday 25 March 2008 16:29:36 Joshua Bronson wrote:
> > I am new to Qt, and I just whipped up a PyQt-based implementation of
> > Tetr*s. I am getting quite a bit of padding between the edges of the
> window
> > and the edges of the area in which the blocks are drawn, and I can't
> seem
> > to figure out how to set this to zero.
> > To see this, svn export the following files:
> > http://aipytris.googlecode.com/svn/trunk/aipytris/g.py
> > http://aipytris.googlecode.com/svn/trunk/aipytris/piece.py
> > http://aipytris.googlecode.com/svn/trunk/aipytris/observable.py
> > http://aipytris.googlecode.com/svn/trunk/aipytris/boardqt.py
> >
> > Then run boardqt.py.
> >
> > Does anyone know how to get rid of this padding?
> >
> > Thanks,
> > Josh
>
> Call setMargin( pixels ) on your layout.
>
> Matt
>

Thanks Matt, that did the trick.

Another question has come up. When implementing this in less sophisticated
Gui frameworks<http://aipytris.googlecode.com/svn/trunk/aipytris/boardtk.py>,
I noticed that the canvas remembered primitives that had already been
painted on it, so on each paint event I only had to paint blocks that had
moved since the previous paint event, which I assume is more efficient. With
my Qt version, however, I am repainting every block on every paint event,
even ones that have not moved. Is there some way around this? I've looked at
the painting examples and read http://doc.trolltech.com/4.3/paintsystem.html,
but I haven't found anything about whether QWidgets can retain state.

Thanks,
Josh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20080326/80a8ae24/attachment.html


More information about the PyQt mailing list