]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/FloatBar.py
doc tweaks, typo fixed, etc.
[wxWidgets.git] / wxPython / demo / FloatBar.py
1 # 11/18/2003 - Jeff Grimmett (grimmtooth@softhome.net)
2 #
3 # o Updated for wx namespace
4 # o OK, Main.py indicates this is deprecated. But I don't see a
5 # replacement yet. So conversion is done anyway.
6 #
7 # 11/28/2003 - Jeff Grimmett (grimmtooth@softhome.net)
8 #
9 # o Issues - library has to be converted to work properly
10 # with new namespace.
11 #
12 # 12/18/2003 - Jeff Grimmett (grimmtooth@softhome.net)
13 #
14 # o wxFloatBar -> FloatBar
15 #
16
17 import wx
18 import wx.lib.floatbar
19
20 import images
21
22
23 class TestFloatBar(wx.Frame):
24 def __init__(self, parent, log):
25 wx.Frame.__init__(
26 self, parent, -1, 'Test ToolBar', wx.DefaultPosition, (500, 300)
27 )
28
29 self.log = log
30
31 win = wx.Window(self, -1)
32 win.SetBackgroundColour("WHITE")
33 wx.StaticText(
34 win, -1, "Drag the toolbar to float it,\n"
35 "Toggle the last tool to remove\nthe title.", (15,15)
36 )
37
38 tb = wx.lib.floatbar.FloatBar(self, -1)
39 self.SetToolBar(tb)
40 tb.SetFloatable(1)
41 tb.SetTitle("Floating!")
42 self.CreateStatusBar()
43
44 tb.AddSimpleTool(10, images.getNewBitmap(), "New", "Long help for 'New'")
45 self.Bind(wx.EVT_TOOL, self.OnToolClick, id=10)
46 self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=10)
47
48 tb.AddSimpleTool(20, images.getOpenBitmap(), "Open")
49 self.Bind(wx.EVT_TOOL, self.OnToolClick, id=20)
50 self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=20)
51
52 tb.AddSeparator()
53 tb.AddSimpleTool(30, images.getCopyBitmap(), "Copy")
54 self.Bind(wx.EVT_TOOL, self.OnToolClick, id=30)
55 self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=30)
56
57 tb.AddSimpleTool(40, images.getPasteBitmap(), "Paste")
58 self.Bind(wx.EVT_TOOL, self.OnToolClick, id=40)
59 self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=40)
60
61 tb.AddSeparator()
62
63 tb.AddCheckTool(60, images.getTog1Bitmap(), images.getTog2Bitmap())
64 self.Bind(wx.EVT_TOOL, self.OnToolClick, id=60)
65 self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=60)
66
67 tb.Realize()
68
69 self.tb = tb
70 self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
71
72
73 def OnCloseWindow(self, event):
74 self.Destroy()
75
76 def OnToolClick(self, event):
77 self.log.WriteText("tool %s clicked\n" % event.GetId())
78
79 if event.GetId() == 60:
80 print event.GetExtraLong(), event.IsChecked(), event.GetInt(), self.tb.GetToolState(60)
81
82 if event.GetExtraLong():
83 self.tb.SetTitle("")
84 else:
85 self.tb.SetTitle("Floating!")
86
87 def OnToolRClick(self, event):
88 self.log.WriteText("tool %s right-clicked\n" % event.GetId())
89
90 #---------------------------------------------------------------------------
91
92 def runTest(frame, nb, log):
93 win = TestFloatBar(frame, log)
94 frame.otherWin = win
95 win.Show(True)
96
97 #---------------------------------------------------------------------------
98
99 overview = """\
100 FloatBar is a subclass of wx.ToolBar, implemented in Python, which
101 can be detached from its frame.
102
103 Drag the toolbar with the mouse to make it float, and drag it back, or
104 close it to make the toolbar return to its original position.
105
106 """
107
108 if __name__ == '__main__':
109 import sys,os
110 import run
111 run.main(['', os.path.basename(sys.argv[0])])
112
113
114
115
116
117
118
119
120
121
122
123
124