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
) 
  20         #tb = wxToolBarSimple(self, -1, wxDefaultPosition, wxDefaultSize, 
  21         #               wxTB_HORIZONTAL | wxNO_BORDER | wxTB_FLAT) 
  24         self
.CreateStatusBar() 
  26         tb
.AddSimpleTool(10, images
.getNewBitmap(), "New", "Long help for 'New'") 
  27         EVT_TOOL(self
, 10, self
.OnToolClick
) 
  28         EVT_TOOL_RCLICKED(self
, 10, self
.OnToolRClick
) 
  30         tb
.AddSimpleTool(20, images
.getOpenBitmap(), "Open", "Long help for 'Open'") 
  31         EVT_TOOL(self
, 20, self
.OnToolClick
) 
  32         EVT_TOOL_RCLICKED(self
, 20, self
.OnToolRClick
) 
  35         tb
.AddSimpleTool(30, images
.getCopyBitmap(), "Copy", "Long help for 'Copy'") 
  36         EVT_TOOL(self
, 30, self
.OnToolClick
) 
  37         EVT_TOOL_RCLICKED(self
, 30, self
.OnToolRClick
) 
  39         tb
.AddSimpleTool(40, images
.getPasteBitmap(), "Paste", "Long help for 'Paste'") 
  40         EVT_TOOL(self
, 40, self
.OnToolClick
) 
  41         EVT_TOOL_RCLICKED(self
, 40, self
.OnToolRClick
) 
  45         tool 
= tb
.AddCheckTool(50, images
.getTog1Bitmap(), 
  46                                shortHelp
="Toggle this") 
  47         EVT_TOOL(self
, 50, self
.OnToolClick
) 
  49         #tb.AddCheckTool(60, '', images.getTog1Bitmap(), images.getTog2Bitmap(), 
  50         #                shortHelp="Toggle with 2 bitmaps") 
  51         #EVT_TOOL(self, 60, self.OnToolClick) 
  53         EVT_TOOL_ENTER(self
, -1, self
.OnToolEnter
) 
  54         EVT_TOOL_RCLICKED(self
, -1, self
.OnToolRClick
)  # Match all 
  55         EVT_TIMER(self
, -1, self
.OnClearSB
) 
  57         if wxPlatform 
!= "__WXMAC__": 
  60             tb
.AddControl(wxComboBox(tb
, cbID
, "", choices
=["", "This", "is a", "wxComboBox"], 
  61                                      size
=(150,-1), style
=wxCB_DROPDOWN
)) 
  62             EVT_COMBOBOX(self
, cbID
, self
.OnCombo
) 
  67     def OnToolClick(self
, event
): 
  68         self
.log
.WriteText("tool %s clicked\n" % event
.GetId()) 
  70     def OnToolRClick(self
, event
): 
  71         self
.log
.WriteText("tool %s right-clicked\n" % event
.GetId()) 
  73     def OnCombo(self
, event
): 
  74         self
.log
.WriteText("combobox item selected: %s\n" % event
.GetString()) 
  76     def OnToolEnter(self
, event
): 
  77         self
.log
.WriteText('OnToolEnter: %s, %s\n' % (event
.GetId(), event
.GetInt())) 
  78         if self
.timer 
is None: 
  79             self
.timer 
= wxTimer(self
) 
  80         if self
.timer
.IsRunning(): 
  82         self
.timer
.Start(2000) 
  86     def OnClearSB(self
, event
):  # called for the timer event handler 
  87         self
.SetStatusText("") 
  92     def OnCloseWindow(self
, event
): 
  93         if self
.timer 
is not None: 
  98 #--------------------------------------------------------------------------- 
 100 def runTest(frame
, nb
, log
): 
 101     win 
= TestToolBar(frame
, log
) 
 105 #---------------------------------------------------------------------------