At first, I couldn't get this example to work either, but then it just
started working. It looks like it works as long as you double-click on
a cell that is not already selected. If you select a cell and then
double-click that same cell, it does not work.
There really isn't a good way to prevent the events from happening. The first click in a double click series always results in a EVT_LEFT_DOWN and EVT_LEFT_UP and then if the next click is soon enough then it results in the EVT_LEFT_DCLICK. The Grid catches these and processes them to generate its own events. There is no way to tell the system to not send the events for the first click if it's going to really be a double click, because by the time it knows that it will be too late.
···
On 2/2/10 7:00 AM, Ron Barak wrote:
Hi,
In the below code, if I double click with the mouse in a grid's cell,
I get:
on_grid_selected_cell
on_grid_cell_left_dclick
Is there something I could change in the code to get only
"on_grid_cell_left_dclick" ?
Traceback (most recent call last):
File "svm_ts_tool_in_progress.py", line 515, in OnSelectCell
clickEvent = wx.CommandEvent(wx.grid.EVT_GRID_LABEL_LEFT_DCLICK,
self.table.GetId())
File "c:\Python25\lib\site-packages\wx-2.8-msw-unicode\wx\_core.py",
line 4560, in __init__
_core_.CommandEvent_swiginit(self,_core_.new_CommandEvent(*args,
**kwargs))
TypeError: in method 'new_CommandEvent', expected argument 1 of type
'wxEventType'
Could you suggest what should I change ?
Thanks,
Ron.
···
On Feb 3, 3:17 am, Robin Dunn <ro...@alldunn.com> wrote:
On 2/2/10 7:00 AM, Ron Barak wrote:
> Hi,
> In the below code, if I double click with the mouse in a grid's cell,
> I get:
> Is there something I could change in the code to get only
> "on_grid_cell_left_dclick" ?
There really isn't a good way to prevent the events from happening. The
first click in a double click series always results in a EVT_LEFT_DOWN
and EVT_LEFT_UP and then if the next click is soon enough then it
results in the EVT_LEFT_DCLICK. The Grid catches these and processes
them to generate its own events. There is no way to tell the system to
not send the events for the first click if it's going to really be a
double click, because by the time it knows that it will be too late.
--
Robin Dunn
Software Craftsmanhttp://wxPython.org
There are two problems. The noticeable one is that you are passing the wrong thing for the eventType. Try using wx.grid.EVT_GRID_LABEL_LEFT_DCLICK.typeId.
The second problem is that I think you are using the wrong event class. It's probably a wx.grid.GirdEvent. Check what is being passed to your event handler to be sure.
···
On 2/3/10 3:45 AM, Ron Barak wrote:
On a slight tangent: Is there a way to simulate a mouse DCLICK ?
Following examples on the web, I produced:
Traceback (most recent call last):
File "svm_ts_tool_in_progress.py", line 515, in OnSelectCell
clickEvent = wx.CommandEvent(wx.grid.EVT_GRID_LABEL_LEFT_DCLICK,
self.table.GetId())
File "c:\Python25\lib\site-packages\wx-2.8-msw-unicode\wx\_core.py",
line 4560, in __init__
_core_.CommandEvent_swiginit(self,_core_.new_CommandEvent(*args,
**kwargs))
TypeError: in method 'new_CommandEvent', expected argument 1 of type
'wxEventType'
> Traceback (most recent call last):
> File "svm_ts_tool_in_progress.py", line 515, in OnSelectCell
> clickEvent = wx.CommandEvent(wx.grid.EVT_GRID_LABEL_LEFT_DCLICK,
> self.table.GetId())
> File "c:\Python25\lib\site-packages\wx-2.8-msw-unicode\wx\_core.py",
> line 4560, in __init__
> _core_.CommandEvent_swiginit(self,_core_.new_CommandEvent(*args,
> **kwargs))
> TypeError: in method 'new_CommandEvent', expected argument 1 of type
> 'wxEventType'
> Could you suggest what should I change ?
There are two problems. The noticeable one is that you are passing the
wrong thing for the eventType. Try using
wx.grid.EVT_GRID_LABEL_LEFT_DCLICK.typeId.
The second problem is that I think you are using the wrong event class.
It's probably a wx.grid.GirdEvent. Check what is being passed to your
event handler to be sure.
--
Robin Dunn
Software Craftsmanhttp://wxPython.org