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