]>
git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/demo/wxFloatBar.py
1 from wxPython
. wx
import *
2 from wxPython
. lib
. floatbar
import *
4 class TestFloatBar ( wxFrame
):
5 def __init__ ( self
, parent
, log
):
6 wxFrame
.__ init
__ ( self
, parent
, - 1 , 'Test ToolBar' ,
7 wxPoint ( 0 , 0 ), wxSize ( 500 , 300 ))
10 wxWindow ( self
, - 1 ). SetBackgroundColour ( wxNamedColour ( "WHITE" ))
12 tb
= wxFloatBar ( self
, - 1 )
15 tb
. SetTitle ( "Floating!" )
16 self
. CreateStatusBar ()
17 tb
. AddTool ( 10 , wxBitmap ( 'bitmaps/new.bmp' , wxBITMAP_TYPE_BMP
),
18 wxNullBitmap
, false
, - 1 , - 1 , "New" , "Long help for 'New'" )
19 EVT_TOOL ( self
, 10 , self
. OnToolClick
)
20 EVT_TOOL_RCLICKED ( self
, 10 , self
. OnToolRClick
)
22 tb
. AddTool ( 20 , wxBitmap ( 'bitmaps/open.bmp' , wxBITMAP_TYPE_BMP
),
23 wxNullBitmap
, false
, - 1 , - 1 , "Open" )
24 EVT_TOOL ( self
, 20 , self
. OnToolClick
)
25 EVT_TOOL_RCLICKED ( self
, 20 , self
. OnToolRClick
)
28 tb
. AddTool ( 30 , wxBitmap ( 'bitmaps/copy.bmp' , wxBITMAP_TYPE_BMP
),
29 wxNullBitmap
, false
, - 1 , - 1 , "Copy" )
30 EVT_TOOL ( self
, 30 , self
. OnToolClick
)
31 EVT_TOOL_RCLICKED ( self
, 30 , self
. OnToolRClick
)
33 tb
. AddTool ( 40 , wxBitmap ( 'bitmaps/paste.bmp' , wxBITMAP_TYPE_BMP
),
34 wxNullBitmap
, false
, - 1 , - 1 , "Paste" )
35 EVT_TOOL ( self
, 40 , self
. OnToolClick
)
36 EVT_TOOL_RCLICKED ( self
, 40 , self
. OnToolRClick
)
40 tb
. AddTool ( 50 , wxBitmap ( 'bitmaps/tog1.bmp' , wxBITMAP_TYPE_BMP
),
41 wxNullBitmap
, true
, - 1 , - 1 , "Toggle this" )
42 EVT_TOOL ( self
, 50 , self
. OnToolClick
)
43 EVT_TOOL_RCLICKED ( self
, 50 , self
. OnToolRClick
)
45 tb
. AddTool ( 60 , wxBitmap ( 'bitmaps/tog1.bmp' , wxBITMAP_TYPE_BMP
),
46 wxBitmap ( 'bitmaps/tog2.bmp' , wxBITMAP_TYPE_BMP
),
47 true
, - 1 , - 1 , "Toggle with 2 bitmaps" )
48 EVT_TOOL ( self
, 60 , self
. OnToolClick
)
49 EVT_TOOL_RCLICKED ( self
, 60 , self
. OnToolRClick
)
51 # b = wxButton(tb, -1, "HELLO!")
52 # EVT_BUTTON(b, b.GetId(), self.test)
55 def OnCloseWindow ( self
, event
):
58 def OnToolClick ( self
, event
):
59 self
. log
. WriteText ( "tool %s clicked \n " % event
. GetId ())
61 def OnToolRClick ( self
, event
):
62 self
. log
. WriteText ( "tool %s right-clicked \n " % event
. GetId ())
63 # def test(self, event):
64 # self.log.WriteText("Button clicked!")
66 #---------------------------------------------------------------------------
68 def runTest ( frame
, nb
, log
):
69 win
= TestFloatBar ( frame
, log
)
73 #---------------------------------------------------------------------------
76 wxFloatBar is a subclass of wxToolBar, implemented in Python, which can be detached from its frame.
78 Drag the toolbar with the mouse to make it float, and drag it back, or close it to make the toolbar
80 return to its original position.
83 -----------------------
87 wxFloatBar(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTB_HORIZONTAL | wxNO_BORDER, const wxString& name = wxPanelNameStr)
89 Constructs a floatable toolbar.
94 parent = Pointer to a parent window.
96 id = Window identifier. If -1, will automatically create an identifier.
98 pos = Window position. wxDefaultPosition is (-1, -1) which indicates that wxWindows should generate a default position for the window. If using the wxWindow class directly, supply an actual position.
100 size = Window size. wxDefaultSize is (-1, -1) which indicates that wxWindows should generate a default size for the window.
102 style = Window style. Se wxToolBar for details.