<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#ffffff" text="#000000">
<font size="+1">hello,<br>
<br>
This might be a strange question, but as a practical guy, I'm not
searching for the best solution, but for a practical solution.<br>
<br>
I've a class which I've used very extensively.<br>
Now I want to extend that class with an action on a double click event,
but that action is determined by the main program.<br>
Normally I would create an derived class and add that specific action.<br>
But I find it too much effort in this specific case, half of the
instances need the extension, half of it dont.<br>
So I want to change the behavior of the class dynamically.<br>
I've done it by adding a global variable (</font><font size="+1"><tt>Base_Grid_Double_Click)
</tt></font><font size="+1">in the module,<br>
initial set to None,<br>
but can be changed by the main program to some callback function.<br>
(see the code below)<br>
Is this a valid construction ( sorry I'm not a programmer),<br>
or are there better ways to accomplish similar dynamic behavior ?<br>
<br>
thanks,<br>
Stef Mientki<br>
<br>
<br>
<br>
</font><font size="+1"><tt>#== module grid_library ==<br>
<br>
Base_Grid_Double_Click = None<br>
<br>
class Base_Grid ( wx.grid.Grid ) :<br>
  def __init__ ( self, ....<br>
<br>
    self.Bind ( gridlib.EVT_GRID_CELL_LEFT_DCLICK ,
self._On_Double_Click )<br>
    <br>
<br>
  def _On_Double_Click ( self, event ) :<br>
    if Base_Grid_Double_Click :<br>
      Row = event.Row<br>
      Col = event.Col<br>
      Col_Label = self.GetColLabelValue ( Col )<br>
      Row_Label = self.GetRowLabelValue ( Row )<br>
      Base_Grid_Double_Click ( self.GetCellValue ( Row, Col ),<br>
                               Col_Label, Row_Label )<br>
    else :<br>
      event.Skip ()<br>
</tt></font><font size="+1"><br>
</font>
</body>
</html>