Hi all,
The subject title is a little bit exagerated, but
I have to face an interesting problem.
It has been said, wx.Frame is more speaking to a
a C++ programmer than a wxFrame, because Frame
is clearly a 'member' of wx. (I'm not a c++ expert)
Now, look at the following functional application.
It uses wx and stc.
···
#-----------------------------------------------
import wx
from wx import stc
#-----------------------------------------------
class MyStc(stc.StyledTextCtrl):
def __init__(self, parent, id, pos , size):
style = wx.SUNKEN_BORDER
stc.StyledTextCtrl.__init__(self, parent, id, pos,
size, style)
print stc.STC_STYLE_DEFAULT
wx.EVT_KEY_UP(self, self.OnKeyDown)
stc.EVT_STC_UPDATEUI(self, id, self.OnUpdateUI)
def OnUpdateUI(self, event):
print 'OnUpdateUI'
event.Skip()
def OnKeyDown(self, event):
print 'OnKeyDown'
event.Skip()
def OnKeyUp(self, event):
print 'OnKeyUp'
event.Skip()
#-----------------------------------------------
class MyFrame(wx.Frame):
def __init__(self, parent, id, title, pos, size):
style = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, parent, id, title, pos,
size, style)
wx.EVT_CLOSE(self, self.OnCloseWindow)
#no panel but a single stc control
wi, he = self.GetClientSize()
self.mystc = MyStc(self, -1, wx.DefaultPosition,
wx.Size(wi, he))
def OnCloseWindow(self, event):
self.Destroy()
#----------------------------------------------------
class MyApp(wx.App):
def OnInit(self):
frame = MyFrame(None, -1, 'newstc', wx.Point(0, 0),
wx.Size(500, 400))
frame.Show(True)
self.SetTopWindow(frame)
return True
#-----------------------------------------------------------
def main():
app = MyApp(0)
app.MainLoop()
#----------------------------------------------------------
if __name__ == "__main__" :
main()
#eof------------------------------------------------------
The two events in the stc are:
wx.EVT_KEY_UP(self, self.OnKeyDown)
stc.EVT_STC_UPDATEUI(self, id, self.OnUpdateUI)
This may look a little bit confusing. Both events are
applying on the stc. But one is a wx member, the other one
is a stc member! Replacing wx.EVT_KEY_UP by stc.EVT_KEY_UP
will not work.
Why does the stc class not inherit the wx events?
The same thinking apply to wx.SUNKEN_BORDER.
Another remark i brief:
The renaming process replaces wx.wxFrame by wx.Frame .
In the case of a stc (grid?, html?), the same renaming leads
to a STC_STYLE_DEFAULT instead of a wxSTC_STYLE_DEFAULT.
Why not a renaming that replace wxSTC prefix. This will
avoid code like stc.STC_STYLE_DEFAULT.
Jean-Michel Fauth, Switzerland