PyQt - 用于重绘的清除小部件 [英] PyQt - clear widget for redraw
问题描述
我想在小部件上绘制一些线条。
这样可行,但是当我想重绘时,旧的线条仍在那里。
如何清除或刷新小部件,以便我可以绘制一组新的线条?
下面的代码片段。
TIA
彼得
---------------------- ---
def paintLines(self,e):
p = QPainter(e)
mar = e.width()/ 100#保证金
vsp = 2#垂直间距
hrz =(e.width() - 2 * mar)/ 100#horizontal scalar
for我在范围(100):
p.drawLine(mar,mar + vsp * i,hrz *(l1 [i] +1),mar + vsp * i)
-------------------------
< blockquote> Peter写道:
我想在小部件上绘制一些线条。
这样可行,但是当我想重绘时,旧的线条是还在那里。
如何清除或刷新小部件,所以我可以画一个新的一行?
在小部件上调用擦除。或者自己重绘一个矩形。
-
问候,
Diez B. Roggisch
Diez B. Roggisch写道:
在您的小部件上调用擦除。或者自己重新绘制一个矩形。
谢谢,这很好。
我昨天刚开始使用pyqt,但找不到参考
- 大多数Qt的东西是为c ++编写的。
彼得
Peter写道:
Diez B. Roggisch写道:
在您的小部件上调用擦除。或者自己重新绘制一个矩形。
谢谢,这很好。
昨天我刚开始使用pyqt,并且无法找到
参考 - 大多数Qt的东西是为c ++写的。
Peter
Boudewijn Rempt'的书_GUI Python编程:QT版_
可能会有所帮助。可在线获取:
http:// www .opendocspublishing.com / pyqt /
您也可以在以下网址发布您的问题:
PyKDE邮件列表 Py *** @ mats.imk.fraunhofer.de
注册列表:
http://mats.imk.fraunhofer.de/mailman/ listinfo / pykde
还有一个PyQt维基:
http://www.diotavelli.net/PyQtWiki
(这是相当新的,有点内容,但那里已经有一些
好东西了。)
Jim
I want to draw some lines on a widget.
This works ok, but when I want to redraw, the old lines are still there.
How do I clear or refresh the widget, so I can draw a new set of lines?
Code snip below.
TIA
Peter
-------------------------
def paintLines(self, e):
p = QPainter(e)
mar = e.width()/100 # margin
vsp = 2 # vertical spacing
hrz = (e.width() - 2*mar)/100 # horizontal scalar
for i in range(100):
p.drawLine(mar,mar+vsp*i,hrz*(l1[i]+1),mar+vsp*i)
-------------------------
Peter wrote:
I want to draw some lines on a widget.
This works ok, but when I want to redraw, the old lines are still there.
How do I clear or refresh the widget, so I can draw a new set of lines?
Call erase on your widget. Or redraw a rectangle yourself.
--
Regards,
Diez B. Roggisch
Diez B. Roggisch wrote:
Call erase on your widget. Or redraw a rectangle yourself.
Thanks, that works fine.
I just started using pyqt yesterday, and having trouble finding a reference
- most Qt stuff is written for c++.
Peter
Peter wrote:
Diez B. Roggisch wrote:
Call erase on your widget. Or redraw a rectangle yourself.
Thanks, that works fine.
I just started using pyqt yesterday, and having trouble finding a
reference - most Qt stuff is written for c++.
Peter
Boudewijn Rempt''s book _GUI Programming with Python: QT Edition_
might be helpful. It''s available online at:
http://www.opendocspublishing.com/pyqt/
You can also post your questions at:
PyKDE mailing list Py***@mats.imk.fraunhofer.de
sign up for the list at:
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
There''s also a PyQt wiki at:
http://www.diotavelli.net/PyQtWiki
(it''s fairly new and a little light on content, but there''s already some
good stuff there).
Jim
这篇关于PyQt - 用于重绘的清除小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!