Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #62964

Re: Retaining drawing across paintevents

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.008
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'url:sourceforge': 0.03; '(so': 0.07; 'lines,': 0.07; 'instance.': 0.09; 'toolkit': 0.09; 'cc:addr:python-list': 0.11; 'jan': 0.12; 'coordinates': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'implies': 0.16; 'qt,': 0.16; 'reasonably': 0.16; 'wrote:': 0.18; 'else,': 0.19; 'thu,': 0.19; 'widget': 0.19; 'not,': 0.20; 'saying': 0.22; 'cc:addr:python.org': 0.22; 'instance,': 0.24; 'tells': 0.24; 'looks': 0.24; 'cc:2**0': 0.24; 'mention': 0.26; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'rest': 0.29; 'am,': 0.29; 'restrict': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'lines': 0.31; 'that.': 0.31; '"please': 0.31; '"the': 0.34; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'event,': 0.36; 'possible': 0.36; 'similar': 0.36; 'should': 0.36; 'too': 0.37; 'area': 0.37; 'ahead': 0.38; 'sure': 0.39; 'even': 0.60; 'new': 0.61; 'simply': 0.61; "you're": 0.61; 'complete': 0.62; 'effectively': 0.66; 'fast,': 0.84; 'fortunately': 0.84; 'windowing': 0.84; 'trouble.': 0.91; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=aTn4+a8KsYfm4TRmontXoyc7dVnt3LePZYIe6g03QG4=; b=NTtF9r1wFbTft8HmVyHosDWCoFmLGFGFN0rO5kckzTD8i1FhcAfeqmY42h448ebJko ZgrldMT44Bpkn13V+lwKzNKKpm5K0hkg5V9InVttLQUl8P6eYTq/TT/KmOU9Ojx2yxSr OOxxFch0GQeVTgJlFtpprpTnms5ZAL2LRGQ44K8hLLUP28frPlyvbi1Zkzv2DFoT+MGk wA0+NnUV7gDzQ0M41gi28Hoe3EED0ZggGrqlcx/QGWQr562sAGtn1wKs/clNUYFuMxYW X7B1eA5M8w0zcg+ypEgqnKP+uI9vpUBWYl7OK6PKHgreAnFseSgo2lDpyH2OILE9KS1r Te4g==
MIME-Version 1.0
X-Received by 10.66.163.36 with SMTP id yf4mr17131606pab.67.1388588756296; Wed, 01 Jan 2014 07:05:56 -0800 (PST)
In-Reply-To <396bc9f8-2ed6-4ebf-853d-a50e3c7ce521@googlegroups.com>
References <396bc9f8-2ed6-4ebf-853d-a50e3c7ce521@googlegroups.com>
Date Thu, 2 Jan 2014 02:05:56 +1100
Subject Re: Retaining drawing across paintevents
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4782.1388588765.18130.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1388588765 news.xs4all.nl 2881 [2001:888:2000:d::a6]:50891
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:62964

Show key headers only | View raw


On Thu, Jan 2, 2014 at 1:53 AM,  <angedward3@gmail.com> wrote:
> I find that I have to re-paint the whole widget every time I call an update(), as I have create a new QPainter() instance. Is there a way to update only a small part of the widget, while retaining the rest of the widget?

In general, it would help to say which windowing toolkit you're using
:) Fortunately you mention something that implies you're using QT, so
I'm going to forge ahead with that.

When you call update(), you're effectively saying "the whole object
needs to be repainted". If you can restrict that to just a particular
rectangle, simply pass those coordinates to the update call:

http://pyqt.sourceforge.net/Docs/PyQt4/qwidget.html#update-4

I'm not sure if you're using PyQt4 or not, but if you're using
something else, look through its docs for a similar function. Same
goes for pretty much any windowing toolkit; it's always possible to
report that a small area needs updating.

Once you then get the update event, you should be given a rectangle
that tells you which part needs to be repainted. But painting outside
that area will be reasonably fast, so don't stress too much about that
part if it's a lot of trouble. For instance, I have a MUD client that
will always attempt to draw complete lines, even if only part of a
line needs to be redrawn - but it'll repaint only those lines which
need repainting (so it looks at the Y coordinates of the "please
repaint me" rectangle, but not the X coords).

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Retaining drawing across paintevents angedward3@gmail.com - 2014-01-01 06:53 -0800
  Re: Retaining drawing across paintevents Chris Angelico <rosuav@gmail.com> - 2014-01-02 02:05 +1100

csiph-web