]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/wxFloatBar.py
reSWIGged
[wxWidgets.git] / wxPython / demo / wxFloatBar.py
CommitLineData
8fa876ca
RD
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#
33785d9f
RD
12# 12/18/2003 - Jeff Grimmett (grimmtooth@softhome.net)
13#
14# o wxFloatBar -> FloatBar
15#
f0261a72 16
8fa876ca 17import wx
33785d9f 18import wx.lib.floatbar
96bfd053 19
8fa876ca 20import images
96bfd053 21
8fa876ca
RD
22
23class TestFloatBar(wx.Frame):
f0261a72 24 def __init__(self, parent, log):
8fa876ca
RD
25 wx.Frame.__init__(
26 self, parent, -1, 'Test ToolBar', wx.DefaultPosition, (500, 300)
27 )
28
f0261a72
RD
29 self.log = log
30
8fa876ca
RD
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 )
f0261a72 37
33785d9f 38 tb = wx.lib.floatbar.FloatBar(self, -1)
f0261a72
RD
39 self.SetToolBar(tb)
40 tb.SetFloatable(1)
41 tb.SetTitle("Floating!")
42 self.CreateStatusBar()
96bfd053 43
70a357c2 44 tb.AddSimpleTool(10, images.getNewBitmap(), "New", "Long help for 'New'")
8fa876ca
RD
45 self.Bind(wx.EVT_TOOL, self.OnToolClick, id=10)
46 self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=10)
f0261a72 47
70a357c2 48 tb.AddSimpleTool(20, images.getOpenBitmap(), "Open")
8fa876ca
RD
49 self.Bind(wx.EVT_TOOL, self.OnToolClick, id=20)
50 self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=20)
f0261a72
RD
51
52 tb.AddSeparator()
70a357c2 53 tb.AddSimpleTool(30, images.getCopyBitmap(), "Copy")
8fa876ca
RD
54 self.Bind(wx.EVT_TOOL, self.OnToolClick, id=30)
55 self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=30)
f0261a72 56
70a357c2 57 tb.AddSimpleTool(40, images.getPasteBitmap(), "Paste")
8fa876ca
RD
58 self.Bind(wx.EVT_TOOL, self.OnToolClick, id=40)
59 self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=40)
f0261a72
RD
60
61 tb.AddSeparator()
62
70a357c2 63 tb.AddCheckTool(60, images.getTog1Bitmap(), images.getTog2Bitmap())
8fa876ca
RD
64 self.Bind(wx.EVT_TOOL, self.OnToolClick, id=60)
65 self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=60)
66
f0261a72 67 tb.Realize()
944930d5
RD
68
69 self.tb = tb
8fa876ca 70 self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
f0261a72
RD
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())
8fa876ca 78
944930d5 79 if event.GetId() == 60:
33785d9f 80 print event.GetExtraLong(), event.IsChecked(), event.GetInt(), self.tb.GetToolState(60)
8fa876ca 81
944930d5
RD
82 if event.GetExtraLong():
83 self.tb.SetTitle("")
84 else:
85 self.tb.SetTitle("Floating!")
f0261a72
RD
86
87 def OnToolRClick(self, event):
88 self.log.WriteText("tool %s right-clicked\n" % event.GetId())
f0261a72
RD
89
90#---------------------------------------------------------------------------
91
92def runTest(frame, nb, log):
93 win = TestFloatBar(frame, log)
94 frame.otherWin = win
1e4a197e 95 win.Show(True)
f0261a72
RD
96
97#---------------------------------------------------------------------------
98
99overview = """\
33785d9f 100FloatBar is a subclass of wx.ToolBar, implemented in Python, which
1fded56b 101can be detached from its frame.
f0261a72 102
1fded56b
RD
103Drag the toolbar with the mouse to make it float, and drag it back, or
104close it to make the toolbar return to its original position.
f0261a72 105
f0261a72
RD
106"""
107
1fded56b
RD
108if __name__ == '__main__':
109 import sys,os
110 import run
111 run.main(['', os.path.basename(sys.argv[0])])
112
113
114
f0261a72
RD
115
116
117
118
119
120
121
122
123
124