We are trying to check for the mouse pointer over a specified area.
It works fine using wxRect but we need to check polygons too.
We don't seem to get wxRegion to work in the same way thow.
The following code:
drawlist = [(0,0),(100,0),(100,100),(0,100)]
region = wxRegion(4,drawlist,wxODDEVEN_RULE)
if region.Contains(event.GetPosition()) == wxInRegion:
Results in:
Traceback (most recent call last):
File "testDwgInput.py", line 207, in onMouseEvents
region = wxRegion(4,drawlist,wxODDEVEN_RULE)
File "C:\Python22\lib\site-packages\wxPython\gdi.py", line 1237, in __init__
self.this = apply(gdic.new_wxRegion,_args,_kwargs)
TypeError: an integer is required
What is "wxODDEVEN_RULE" and is it this or the "drawlist" that's not integer ?
drawlist = [(0,0),(100,0),(100,100),(0,100)]
region = wxRegion(4,drawlist,wxODDEVEN_RULE)
if region.Contains(event.GetPosition()) == wxInRegion:
Results in:
Traceback (most recent call last):
File "testDwgInput.py", line 207, in onMouseEvents
region = wxRegion(4,drawlist,wxODDEVEN_RULE)
File "C:\Python22\lib\site-packages\wxPython\gdi.py", line 1237, in
__init__
self.this = apply(gdic.new_wxRegion,_args,_kwargs)
TypeError: an integer is required
Currently only the (x,y,width,height) wxRegion constructor is wrapped in
wxPython but I've added wxRegionFromPoints for 2.3.3. You'll be able to use
it like this:
region = wxRegionFromPoints(drawlist)
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!