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