3 from wxPython.wx import *
4 from wxPython.dllwidget import wxDllWidget, wxDllWidget_GetDllExt
6 #----------------------------------------------------------------------
8 class TestFrame(wxFrame):
10 wxFrame.__init__(self, None, -1, "Test wxDllWidget")
13 menu.Append(101, "Send command &1")
14 menu.Append(102, "Send command &2")
15 menu.Append(103, "Send command &3")
16 menu.AppendSeparator()
17 menu.Append(110, "E&xit")
20 mb.Append(menu, "&Test")
23 EVT_MENU_RANGE(self, 101, 109, self.OnSendCommand)
24 EVT_MENU(self, 110, self.OnExit)
26 panel = wxPanel(self, -1)
27 panel.SetFont(wxFont(12, wxSWISS, wxNORMAL, wxBOLD))
29 st = wxStaticText(panel, -1,
30 "The widget below was dynamically imported from\n"
31 "test_dll.dll or test_dll.so with no prior knowledge\n"
32 "of it's contents or structure by wxPython.")
34 self.dw = dw = wxDllWidget(panel, -1,
35 "test_dll" + wxDllWidget_GetDllExt(),
40 # The embedded window is the one exported from the DLL
41 print dw.GetWidgetWindow().GetClassName()
43 # This shows that we can give it a child from this side of things.
44 # You can also call any wxWindow methods on it too.
45 wxStaticText(dw.GetWidgetWindow(), -1,
46 "Loaded from test_dll...", pos=(10,10))
48 wxStaticText(dw, -1, "ERROR!!!!", pos=(20,20))
50 sizer = wxBoxSizer(wxVERTICAL)
51 sizer.Add(wxStaticLine(panel, -1), 0, wxGROW)
52 sizer.Add(st, 0, wxGROW|wxALL, 5)
53 sizer.Add(dw, 1, wxGROW|wxALL, 5)
56 panel.SetAutoLayout(true)
58 sizer.SetSizeHints(self)
61 def OnExit(self, evt):
65 def OnSendCommand(self, evt):
66 ID = evt.GetId() - 100 # use the menu ID as the command
69 dlg = wxTextEntryDialog(self, "Enter a colour name to pass to the embedded widget:")
70 if dlg.ShowModal() == wxID_OK:
71 param = dlg.GetValue()
73 self.dw.SendCommand(ID, param)
77 #----------------------------------------------------------------------
80 if __name__ == "__main__":