1999-10-06 02:22:25 -04:00
|
|
|
from wxPython.wx import *
|
|
|
|
from wxPython.lib.floatbar import *
|
|
|
|
|
2001-04-09 15:36:36 -04:00
|
|
|
import images
|
|
|
|
|
|
|
|
|
1999-10-06 02:22:25 -04:00
|
|
|
class TestFloatBar(wxFrame):
|
|
|
|
def __init__(self, parent, log):
|
|
|
|
wxFrame.__init__(self, parent, -1, 'Test ToolBar',
|
|
|
|
wxPoint(0,0), wxSize(500, 300))
|
|
|
|
self.log = log
|
|
|
|
|
1999-11-10 03:03:29 -05:00
|
|
|
win = wxWindow(self, -1)
|
|
|
|
win.SetBackgroundColour(wxNamedColour("WHITE"))
|
|
|
|
wxStaticText(win, -1, "Drag the toolbar to float it,\n"
|
2000-01-04 23:58:23 -05:00
|
|
|
"Toggle the last tool to remove\nthe title.", wxPoint(15,15))
|
1999-10-06 02:22:25 -04:00
|
|
|
|
|
|
|
tb = wxFloatBar(self, -1)
|
|
|
|
self.SetToolBar(tb)
|
|
|
|
tb.SetFloatable(1)
|
|
|
|
tb.SetTitle("Floating!")
|
|
|
|
self.CreateStatusBar()
|
2001-04-09 15:36:36 -04:00
|
|
|
|
2002-03-26 20:10:28 -05:00
|
|
|
tb.AddSimpleTool(10, '', images.getNewBitmap(), "New", "Long help for 'New'")
|
1999-10-06 02:22:25 -04:00
|
|
|
EVT_TOOL(self, 10, self.OnToolClick)
|
|
|
|
EVT_TOOL_RCLICKED(self, 10, self.OnToolRClick)
|
|
|
|
|
2002-03-26 20:10:28 -05:00
|
|
|
tb.AddSimpleTool(20, '', images.getOpenBitmap(), "Open")
|
1999-10-06 02:22:25 -04:00
|
|
|
EVT_TOOL(self, 20, self.OnToolClick)
|
|
|
|
EVT_TOOL_RCLICKED(self, 20, self.OnToolRClick)
|
|
|
|
|
|
|
|
tb.AddSeparator()
|
2002-03-26 20:10:28 -05:00
|
|
|
tb.AddSimpleTool(30, '', images.getCopyBitmap(), "Copy")
|
1999-10-06 02:22:25 -04:00
|
|
|
EVT_TOOL(self, 30, self.OnToolClick)
|
|
|
|
EVT_TOOL_RCLICKED(self, 30, self.OnToolRClick)
|
|
|
|
|
2002-03-26 20:10:28 -05:00
|
|
|
tb.AddSimpleTool(40, '', images.getPasteBitmap(), "Paste")
|
1999-10-06 02:22:25 -04:00
|
|
|
EVT_TOOL(self, 40, self.OnToolClick)
|
|
|
|
EVT_TOOL_RCLICKED(self, 40, self.OnToolRClick)
|
|
|
|
|
|
|
|
tb.AddSeparator()
|
|
|
|
|
|
|
|
|
2002-03-26 20:10:28 -05:00
|
|
|
tb.AddCheckTool(60, '', images.getTog1Bitmap(), images.getTog2Bitmap())
|
1999-10-06 02:22:25 -04:00
|
|
|
EVT_TOOL(self, 60, self.OnToolClick)
|
|
|
|
EVT_TOOL_RCLICKED(self, 60, self.OnToolRClick)
|
|
|
|
tb.Realize()
|
1999-11-10 03:03:29 -05:00
|
|
|
|
|
|
|
self.tb = tb
|
2000-07-15 15:51:35 -04:00
|
|
|
EVT_CLOSE(self, self.OnCloseWindow)
|
1999-10-06 02:22:25 -04:00
|
|
|
|
|
|
|
|
|
|
|
def OnCloseWindow(self, event):
|
|
|
|
self.Destroy()
|
|
|
|
|
|
|
|
def OnToolClick(self, event):
|
|
|
|
self.log.WriteText("tool %s clicked\n" % event.GetId())
|
1999-11-10 03:03:29 -05:00
|
|
|
if event.GetId() == 60:
|
2000-01-04 23:58:23 -05:00
|
|
|
print event.GetExtraLong(), event.Checked(), event.GetInt(), self.tb.GetToolState(60)
|
1999-11-10 03:03:29 -05:00
|
|
|
if event.GetExtraLong():
|
|
|
|
self.tb.SetTitle("")
|
|
|
|
else:
|
|
|
|
self.tb.SetTitle("Floating!")
|
1999-10-06 02:22:25 -04:00
|
|
|
|
|
|
|
def OnToolRClick(self, event):
|
|
|
|
self.log.WriteText("tool %s right-clicked\n" % event.GetId())
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
def runTest(frame, nb, log):
|
|
|
|
win = TestFloatBar(frame, log)
|
|
|
|
frame.otherWin = win
|
|
|
|
win.Show(true)
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
overview = """\
|
|
|
|
wxFloatBar is a subclass of wxToolBar, implemented in Python, which can be detached from its frame.
|
|
|
|
|
1999-11-10 03:03:29 -05:00
|
|
|
Drag the toolbar with the mouse to make it float, and drag it back, or close it to make the toolbar return to its original position.
|
1999-10-06 02:22:25 -04:00
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|