Hello, first of all the question: is it possible to delete a drawing done by
using tools such as dc.drawline or dc.drawcircle?
not su much delete, as re-draw without it.
DCs don't provide any persistance, etc by themselves, you need to
write all that yourself, or use a library someone else as already
written:
wx.lib.floatcanvas: for object-persistant, scalable drawing
wx.lib.ogl: for "boxes with lines" type drawings
If you want to write it from scratch yourself, take a look at the
wiki, with a search for "drawing":
http://wiki.wxpython.org/FrontPage?action=fullsearch&context=180&value=drawing&titlesearch=Titles
Sample file attached
ouch!
def on_paint(self, event):
#painting surface
global dc
you do not want to do this -- first, global is almost never the right
way to do this, second, you really don't want to use it for things
like dcs.
I couldn't help myse4lf, so I re-fatored it for you, see enclosed.
Note that this really needs some more cleaning up. Be sure to check out:
http://wiki.wxpython.org/wxPython%20Style%20Guide
and maybe:
http://wiki.wxpython.org/ModelViewController
and
http://wiki.wxpython.org/ModelViewPresenter
i.e: even if you dont do full-on MVC or MVP, you probably want simpel
data model that captures the sate of the drawing, and have the buttons
change that data model, and have the drawing code draw baed on the
contents of that data model -- the model could be as simple as a dict.
-HTH,
-Chris
wx_draw2.py (2.43 KB)
···
On Tue, Feb 12, 2013 at 7:47 AM, <andreafran@gmail.com> wrote:
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov