Hi !
I don't understand, wxPython why don't push the events to the inherited objects.
Delphi is better in this, because if I want, I can do 3 things:
1. Override the old method, do my things only.
2. Override the old method, call the parent's method, and do my things.
3. Override the old method, do my things, and then call the parent's method.
That is very flexible, because I can avoid some effects, I can control the object fully.
But in wx I see that many objects drop the events, and the inherited object cannot use/receive them. See: "Grid - Select only one cell".
The very bad solution this for make selection:
#Boa:Dialog:dlg_choosepath
import wx
def create(parent):
return dlg_choosepath(parent)
[wxID_DLG_CHOOSEPATH, wxID_DLG_CHOOSEPATHBUTTON1, wxID_DLG_CHOOSEPATHBUTTON2,
wxID_DLG_CHOOSEPATHGDC_MAIN, wxID_DLG_CHOOSEPATHPANEL1,
wxID_DLG_CHOOSEPATHPANEL2, wxID_DLG_CHOOSEPATHTC_PATH,
] = [wx.NewId() for _init_ctrls in range(7)]
[wxID_DLG_CHOOSEPATHTIM_CHANGING] = [wx.NewId() for _init_utils in range(1)]
class dlg_choosepath(wx.Dialog):
def _init_coll_boxSizer3_Items(self, parent):
# generated method, don't edit
parent.AddWindow(self.button1, 0, border=4, flag=wx.ALL)
parent.AddWindow(self.button2, 0, border=4, flag=wx.ALL)
def _init_coll_boxSizer1_Items(self, parent):
# generated method, don't edit
parent.AddWindow(self.panel1, 1, border=0, flag=wx.EXPAND | wx.ALL)
parent.AddWindow(self.panel2, 0, border=0, flag=wx.EXPAND | wx.ALL)
def _init_coll_boxSizer2_Items(self, parent):
# generated method, don't edit
parent.AddWindow(self.gdc_main, 1, border=4, flag=wx.EXPAND | wx.ALL)
parent.AddWindow(self.tc_path, 0, border=4, flag=wx.EXPAND | wx.ALL)
def _init_utils(self):
# generated method, don't edit
self.tim_changing = wx.Timer(id=wxID_DLG_CHOOSEPATHTIM_CHANGING,
owner=self)
self.Bind(wx.EVT_TIMER, self.OnTim_changingTimer,
id=wxID_DLG_CHOOSEPATHTIM_CHANGING)
def _init_sizers(self):
# generated method, don't edit
self.boxSizer1 = wx.BoxSizer(orient=wx.VERTICAL)
self.boxSizer2 = wx.BoxSizer(orient=wx.VERTICAL)
self.boxSizer3 = wx.BoxSizer(orient=wx.HORIZONTAL)
self._init_coll_boxSizer1_Items(self.boxSizer1)
self._init_coll_boxSizer2_Items(self.boxSizer2)
self._init_coll_boxSizer3_Items(self.boxSizer3)
self.SetSizer(self.boxSizer1)
self.panel1.SetSizer(self.boxSizer2)
self.panel2.SetSizer(self.boxSizer3)
def _init_ctrls(self, prnt):
# generated method, don't edit
wx.Dialog.__init__(self, id=wxID_DLG_CHOOSEPATH, name=u'dlg_choosepath',
parent=prnt, pos=wx.Point(445, 223), size=wx.Size(411, 352),
style=wx.DEFAULT_DIALOG_STYLE, title=u'Choose path')
self._init_utils()
self.SetClientSize(wx.Size(403, 318))
self.Center(wx.BOTH)
self.panel1 = wx.Panel(id=wxID_DLG_CHOOSEPATHPANEL1, name='panel1',
parent=self, pos=wx.Point(0, 0), size=wx.Size(403, 287),
style=wx.TAB_TRAVERSAL)
self.panel2 = wx.Panel(id=wxID_DLG_CHOOSEPATHPANEL2, name='panel2',
parent=self, pos=wx.Point(0, 287), size=wx.Size(403, 31),
style=wx.TAB_TRAVERSAL)
self.button1 = wx.Button(id=wxID_DLG_CHOOSEPATHBUTTON1, label=u'Ok',
name='button1', parent=self.panel2, pos=wx.Point(4, 4),
size=wx.Size(75, 23), style=0)
self.button1.Bind(wx.EVT_BUTTON, self.OnButton1Button,
id=wxID_DLG_CHOOSEPATHBUTTON1)
self.button2 = wx.Button(id=wxID_DLG_CHOOSEPATHBUTTON2, label=u'Cancel',
name='button2', parent=self.panel2, pos=wx.Point(87, 4),
size=wx.Size(75, 23), style=0)
self.button2.Bind(wx.EVT_BUTTON, self.OnButton2Button,
id=wxID_DLG_CHOOSEPATHBUTTON2)
self.gdc_main = wx.GenericDirCtrl(defaultFilter=0, dir='.', filter='',
id=wxID_DLG_CHOOSEPATHGDC_MAIN, name=u'gdc_main',
parent=self.panel1, pos=wx.Point(4, 4), size=wx.Size(395, 250),
style=wx.DIRCTRL_3D_INTERNAL | wx.SUNKEN_BORDER)
self.gdc_main.SetLabel(u'gdc_main')
self.gdc_main.Bind(wx.EVT_LEFT_DCLICK, self.OnGdc_mainLeftDclick)
self.gdc_main.Bind(wx.EVT_LEFT_UP, self.OnGdc_mainLeftUp)
self.gdc_main.Bind(wx.EVT_LEFT_DOWN, self.OnGdc_mainLeftDown)
self.gdc_main.Bind(wx.EVT_KEY_UP, self.OnGdc_mainKeyUp)
self.gdc_main.Bind(wx.EVT_KEY_DOWN, self.OnGdc_mainKeyDown)
self.gdc_main.Bind(wx.EVT_CHAR, self.OnGdc_mainChar)
self.gdc_main.Bind(wx.EVT_PAINT, self.OnGdc_mainPaint)
self.tc_path = wx.TextCtrl(id=wxID_DLG_CHOOSEPATHTC_PATH,
name=u'tc_path', parent=self.panel1, pos=wx.Point(4, 262),
size=wx.Size(395, 21), style=wx.TE_READONLY, value='textCtrl1')
self._init_sizers()
def __init__(self, parent):
self._init_ctrls(parent)
self.Path=None
self.tim_changing.Start(10,wx.TIMER_CONTINUOUS)
def OnButton1Button(self, event):
self.OnPathChanged()
self.Path=self.tc_path.GetValue()
self.Close()
event.Skip()
def OnButton2Button(self, event):
self.Close()
event.Skip()
def OnPathChanged(self):
s=self.gdc_main.GetPath()
s2=self.tc_path.GetValue()
if s<>s2:
self.tc_path.SetValue(s)
def OnGdc_mainLeftDclick(self, event):
self.OnPathChanged()
event.Skip()
def OnGdc_mainLeftUp(self, event):
self.OnPathChanged()
event.Skip()
def OnGdc_mainLeftDown(self, event):
self.OnPathChanged()
event.Skip()
def OnGdc_mainKeyUp(self, event):
self.OnPathChanged()
event.Skip()
def OnGdc_mainKeyDown(self, event):
self.OnPathChanged()
event.Skip()
def OnGdc_mainChar(self, event):
self.OnPathChanged()
event.Skip()
def OnGdc_mainPaint(self, event):
self.OnPathChanged()
event.Skip()
def OnTim_changingTimer(self, event):
self.OnPathChanged()
event.Skip()
if __name__ == '__main__':
app = wx.PySimpleApp()
wx.InitAllImageHandlers()
dlg = create(None)
try:
dlg.ShowModal()
finally:
dlg.Destroy()
app.MainLoop()