]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/dllwidget/test_prog.py
42991bd8fcd1384735acb2ae199882551a15c536
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(),
39 # The embedded window is the one exported from the DLL
40 print dw
.GetEmbeddedWindow().GetClassName()
42 # This shows that we can give it a child from this side of things.
43 # You can also call any wxWindow methods on it too.
44 wxStaticText(dw
.GetEmbeddedWindow(), -1,
45 "Loaded from test_dll...", pos
=(10,10))
48 sizer
= wxBoxSizer(wxVERTICAL
)
49 sizer
.Add(wxStaticLine(panel
, -1), 0, wxGROW
)
50 sizer
.Add(st
, 0, wxGROW|wxALL
, 5)
51 sizer
.Add(dw
, 1, wxGROW|wxALL
, 5)
54 panel
.SetAutoLayout(true
)
56 sizer
.SetSizeHints(self
)
59 def OnExit(self
, evt
):
63 def OnSendCommand(self
, evt
):
64 ID
= evt
.GetId() - 100 # use the menu ID as the command
67 dlg
= wxTextEntryDialog(self
, "Enter a colour name to pass to the embedded widget:")
68 if dlg
.ShowModal() == wxID_OK
:
69 param
= dlg
.GetValue()
71 self
.dw
.SendCommand(ID
, param
)
75 #----------------------------------------------------------------------
78 if __name__
== "__main__":