2 from wxPython
.wx
import *
6 #---------------------------------------------------------------------------
8 class TestToolBar(wxFrame
):
9 def __init__(self
, parent
, log
):
10 wxFrame
.__init
__(self
, parent
, -1, 'Test ToolBar',
11 wxPoint(0,0), wxSize(500, 300))
14 EVT_CLOSE(self
, self
.OnCloseWindow
)
16 wxWindow(self
, -1).SetBackgroundColour(wxNamedColour("WHITE"))
18 tb
= self
.CreateToolBar(wxTB_HORIZONTAL|wxNO_BORDER|wxTB_FLAT
)
19 #tb = wxToolBarSimple(self, -1, wxDefaultPosition, wxDefaultSize,
20 # wxTB_HORIZONTAL | wxNO_BORDER | wxTB_FLAT)
23 self
.CreateStatusBar()
25 tb
.AddSimpleTool(10, images
.getNewBitmap(), "New", "Long help for 'New'")
26 EVT_TOOL(self
, 10, self
.OnToolClick
)
27 EVT_TOOL_RCLICKED(self
, 10, self
.OnToolRClick
)
29 tb
.AddSimpleTool(20, images
.getOpenBitmap(), "Open", "Long help for 'Open'")
30 EVT_TOOL(self
, 20, self
.OnToolClick
)
31 EVT_TOOL_RCLICKED(self
, 20, self
.OnToolRClick
)
34 tb
.AddSimpleTool(30, images
.getCopyBitmap(), "Copy", "Long help for 'Copy'")
35 EVT_TOOL(self
, 30, self
.OnToolClick
)
36 EVT_TOOL_RCLICKED(self
, 30, self
.OnToolRClick
)
38 tb
.AddSimpleTool(40, images
.getPasteBitmap(), "Paste", "Long help for 'Paste'")
39 EVT_TOOL(self
, 40, self
.OnToolClick
)
40 EVT_TOOL_RCLICKED(self
, 40, self
.OnToolRClick
)
44 tool
= tb
.AddTool(50, images
.getTog1Bitmap(),
45 shortHelpString
="Toggle this", isToggle
=true
)
46 EVT_TOOL(self
, 50, self
.OnToolClick
)
48 tb
.AddTool(60, images
.getTog1Bitmap(), images
.getTog2Bitmap(),
49 shortHelpString
="Toggle with 2 bitmaps", isToggle
=true
)
50 EVT_TOOL(self
, 60, self
.OnToolClick
)
52 EVT_TOOL_ENTER(self
, -1, self
.OnToolEnter
)
53 EVT_TOOL_RCLICKED(self
, -1, self
.OnToolRClick
) # Match all
54 EVT_TIMER(self
, -1, self
.OnClearSB
)
58 tb
.AddControl(wxComboBox(tb
, cbID
, "", choices
=["", "This", "is a", "wxComboBox"],
59 size
=(150,-1), style
=wxCB_DROPDOWN
))
60 EVT_COMBOBOX(self
, cbID
, self
.OnCombo
)
65 def OnToolClick(self
, event
):
66 self
.log
.WriteText("tool %s clicked\n" % event
.GetId())
68 def OnToolRClick(self
, event
):
69 self
.log
.WriteText("tool %s right-clicked\n" % event
.GetId())
71 def OnCombo(self
, event
):
72 self
.log
.WriteText("combobox item selected: %s\n" % event
.GetString())
74 def OnToolEnter(self
, event
):
75 self
.log
.WriteText('OnToolEnter: %s, %s\n' % (event
.GetId(), event
.GetInt()))
76 if self
.timer
is None:
77 self
.timer
= wxTimer(self
)
78 if self
.timer
.IsRunning():
80 self
.timer
.Start(2000)
84 def OnClearSB(self
, event
): # called for the timer event handler
85 self
.SetStatusText("")
90 def OnCloseWindow(self
, event
):
91 if self
.timer
is not None:
96 #---------------------------------------------------------------------------
98 def runTest(frame
, nb
, log
):
99 win
= TestToolBar(frame
, log
)
103 #---------------------------------------------------------------------------