]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/demo/FloatBar.py
Don't allow parameterless wxDropSource
[wxWidgets.git] / wxPython / demo / FloatBar.py
... / ...
CommitLineData
1#
2# Please note that wx.lib.floatbar is not formally supported as
3# part of wxPython. If it works, fine. If not, unfortunate.
4# GTK users can use the wx.TB_DOCKABLE flag with a regular
5# wx.ToolBar, but everyone else has to take thier chances.
6#
7
8import wx
9import wx.lib.floatbar
10
11import images
12
13
14class TestFloatBar(wx.Frame):
15 def __init__(self, parent, log):
16 wx.Frame.__init__(
17 self, parent, -1, 'Test ToolBar', wx.DefaultPosition, (500, 300)
18 )
19
20 self.log = log
21
22 win = wx.Window(self, -1)
23 win.SetBackgroundColour("WHITE")
24 wx.StaticText(
25 win, -1, "Drag the toolbar to float it,\n"
26 "Toggle the last tool to remove\nthe title.", (15,15)
27 )
28
29 tb = wx.lib.floatbar.FloatBar(self, -1)
30 self.SetToolBar(tb)
31 tb.SetFloatable(1)
32 tb.SetTitle("Floating!")
33 self.CreateStatusBar()
34
35 tb.AddSimpleTool(10, images.getNewBitmap(), "New", "Long help for 'New'")
36 self.Bind(wx.EVT_TOOL, self.OnToolClick, id=10)
37 self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=10)
38
39 tb.AddSimpleTool(20, images.getOpenBitmap(), "Open")
40 self.Bind(wx.EVT_TOOL, self.OnToolClick, id=20)
41 self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=20)
42
43 tb.AddSeparator()
44 tb.AddSimpleTool(30, images.getCopyBitmap(), "Copy")
45 self.Bind(wx.EVT_TOOL, self.OnToolClick, id=30)
46 self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=30)
47
48 tb.AddSimpleTool(40, images.getPasteBitmap(), "Paste")
49 self.Bind(wx.EVT_TOOL, self.OnToolClick, id=40)
50 self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=40)
51
52 tb.AddSeparator()
53
54 tb.AddCheckTool(60, images.getTog1Bitmap(), images.getTog2Bitmap())
55 self.Bind(wx.EVT_TOOL, self.OnToolClick, id=60)
56 self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=60)
57
58 tb.Realize()
59
60 self.tb = tb
61 self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
62
63
64 def OnCloseWindow(self, event):
65 self.Destroy()
66
67 def OnToolClick(self, event):
68 self.log.WriteText("tool %s clicked\n" % event.GetId())
69
70 if event.GetId() == 60:
71 print event.GetExtraLong(), event.IsChecked(), event.GetInt(), self.tb.GetToolState(60)
72
73 if event.GetExtraLong():
74 self.tb.SetTitle("")
75 else:
76 self.tb.SetTitle("Floating!")
77
78 def OnToolRClick(self, event):
79 self.log.WriteText("tool %s right-clicked\n" % event.GetId())
80
81#---------------------------------------------------------------------------
82
83def runTest(frame, nb, log):
84 win = TestFloatBar(frame, log)
85 frame.otherWin = win
86 win.Show(True)
87
88#---------------------------------------------------------------------------
89
90overview = """\
91FloatBar is a subclass of wx.ToolBar, implemented in Python, which
92can be detached from its frame.
93
94Drag the toolbar with the mouse to make it float, and drag it back, or
95close it to make the toolbar return to its original position.
96
97"""
98
99if __name__ == '__main__':
100 import sys,os
101 import run
102 run.main(['', os.path.basename(sys.argv[0])])
103
104
105
106
107
108
109
110
111
112
113
114
115