I'm not quite a beginner, so I can offer not quite an answer.
The short answer is to add
self.curLine =
in your frame initialisation before creating the splash screen.
The longer answer is that I'm guessing that the splash screen captures mouse down events but not motion, so that OnLeftDown in the DoodleWindow instance is never called, hence curLine is never created.
Here's where my wxPython knowledge breaks down. I understood that mouse events do not propagate up the window hierarchy if they are not handled, so I don't know why the DoodleWindow sees the motion event. Doubtless some more knowledgeable person will explain everything, but this should get you going in the meantime.
Phil Mayes
···
At 08:37 PM 5/29/2006, you wrote:
Hi,
I've been giving wxpython a test drive and have been playing around with some of the demo code. During this, I've found that under some circumstances I can cause, an exception in doodle.py demo script if I include a splash screen. When I modify the doodle.py script so it reads as follows
class DoodleFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, -1, "Doodle Frame", size=(800,600),
style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE)
#addition starts here#
image=wx.Image(".\\images\\splashscreen.bmp", wx.BITMAP_TYPE_BMP)
bmp=image.ConvertToBitmap()
wx.SplashScreen(bmp, wx.SPLASH_CENTRE_ON_SCREEN|wx.SPLASH_TIMEOUT,3000,None,-1)
wx.Yield()
#addition ends here#
doodle = DoodleWindow(self, -1)
Running this code everything is fine provided I don't click on the splash screen - in which case the doodle code causes and exception in OnMotion when it tries to access self.curLine - which is not available. If I understand the code correctly its as though the initial click on the splashscreen generates a call to OnMoition()
def OnMotion(self, event):
"""
Called when the mouse is in motion. If the left button is
dragging then draw a line from the last event position to the
current one. Save the coordinants for redraws.
"""
event
if event.Dragging() and event.LeftIsDown():
dc = wx.BufferedDC(wx.ClientDC(self), self.buffer)
dc.BeginDrawing()
dc.SetPen(self.pen)
pos = event.GetPosition()
coords = (self.pos.x, self.pos.y, pos.x, pos.y)
self.curLine.append(coords)
dc.DrawLine(*coords)
self.pos = pos
dc.EndDrawing()
additional background
I'm running python
'2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)]'
under win2k
with
wxPython2.6-win32-ansi-2.6.3.2-py23.exe
Now after this long preamble my question is
Is this problem due to my ignorance about how to handle events in wxpython, or a bug. If as I suspect it is the former ihow can I handle them better so I don't have this problem?
Thankyou
Dominic
Hi,
I've been giving wxpython a test drive and have been playing around with some of the demo code. During this, I've found that under some circumstances I can cause, an exception in doodle.py demo script if I include a splash screen. When I modify the doodle.py script so it reads as follows
class DoodleFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, -1, "Doodle Frame", size=(800,600),
style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE)
#addition starts here#
image=wx.Image(".\\images\\splashscreen.bmp", wx.BITMAP_TYPE_BMP)
bmp=image.ConvertToBitmap()
wx.SplashScreen(bmp, wx.SPLASH_CENTRE_ON_SCREEN|wx.SPLASH_TIMEOUT,3000,None,-1)
wx.Yield()
#addition ends here#
doodle = DoodleWindow(self, -1)
Running this code everything is fine provided I don't click on the splash screen - in which case the doodle code causes and exception in OnMotion when it tries to access self.curLine - which is not available. If I understand the code correctly its as though the initial click on the splashscreen generates a call to OnMoition()
snip
Now after this long preamble my question is
Is this problem due to my ignorance about how to handle events in wxpython, or a bug. If as I suspect it is the former ihow can I handle them better so I don't have this problem?
Thankyou
Dominic
snip
Hi Phil,
Thank you for the feed back-
I'm not quite a beginner, so I can offer not quite an answer.
The short answer is to add
self.curLine =
in your frame initialisation before creating the splash screen.
This seems reasonable but it, sadly, won't make my feeling of ignorance about wxpython events go away
The longer answer is that I'm guessing that the splash screen captures mouse down events but not motion, so that OnLeftDown in the DoodleWindow instance is never called, hence curLine is never created.
Here's where my wxPython knowledge breaks down. I understood that mouse events do not propagate up the window hierarchy if they are not handled, so I don't know why the DoodleWindow sees the motion event. Doubtless some more knowledgeable person will explain everything, but this should get you going in the meantime.
Thank you for the in sigh about the not propagation of mouse events - I wonder if you can force propagation of the left mouse click event- I had though that wx.Skip() might do this but it does not seem to solve the problem.
Phil Mayes
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
Dominic Barraclough, PhD
Center for Visual Science
University of Rochester
274 Meliora Hall - River Campus
Rochester
New York 14627
Tel. (585) 275 1812
Fax.(585) 271-3043
email dominicb@cvs.rochester.edu
group home web page http://www.bcs.rochester.edu/~dlee
···
At 01:21 AM 5/30/2006, you wrote:
At 08:37 PM 5/29/2006, you wrote: