Python CreateToolBar() in wxPython (original) (raw)
Last Updated : 15 May, 2020
In this article we will learn how can we add a toolbar in a frame. A toolbar in a gui application provides quick access to various important tools. We can create toolbar using CreateToolBar() function in wx.Frame class of wxPython.
Syntax : wx.Frame.CreateToolBar(self, style=TB_DEFAULT_STYLE, id=ID_ANY, name=ToolBarNameStr)
Parameters :
Parameter Input Type Description style long The toolbar style. id int The menu item identifier. name string The toolbar window name. Returns : A pointer to the toolbar if it was created successfully, None otherwise.
Code Example :
import
wx
class
Example(wx.Frame):
`` def
__init__(
self
,
*
args,
*
*
kwargs):
`` super
(Example,
self
).__init__(
*
args,
*
*
kwargs)
`` self
.InitUI()
`` def
InitUI(
self
):
`` toolbar
=
self
.CreateToolBar()
`` qtool
=
toolbar.AddTool(wx.ID_ANY,
'Welcome'
, wx.Bitmap(
'/Desktop/wxPython/images.png'
))
`` toolbar.Realize()
`` self
.SetSize((
600
,
400
))
`` self
.SetTitle(
'Simple toolbar'
)
`` self
.Centre()
`` def
OnQuit(
self
, e):
`` self
.Close()
def
main():
`` app
=
wx.App()
`` ex
=
Example(
None
)
`` ex.Show()
`` app.MainLoop()
if
__name__
=
=
'__main__'
:
`` main()
Output :
Similar Reads
- Python - Create() function in wxPython In this particular article we are going to learn about Create() function present in wx.Frame class. Create function is similar to Frame() constructor of wx.Frame class. Create function is used in two-step frame construction. Syntax : wx.Frame.Create(parent, id=ID_ANY, title="", pos=DefaultPosition, 1 min read
- Button in wxPython - Python In this article we are going to learn how can we add buttons to a frame in wxPython. This can be done by using the Button() constructor of wx.Button class. Following styles are supported in this class: wx.BU_LEFT: Left-justifies the label. Windows and GTK+ only.wx.BU_TOP: Aligns the label to the top 2 min read
- wxPython | GetToolByPos() function in python In this article we are going to learn about GetToolByPos() function present in wx.ToolBar class of wxPython. GetToolByPos() function is used to simply return a pointer to the tool at specific position. GetToolByPos() function takes a single parameter that is pos(position of tool). Syntax: wx.ToolBar 2 min read
- wxPython | GetToolPos() function in python In this article we are going to learn about GetToolPos() function associated with wx.ToolBar class of wxPython. GetToolPos() function simply returns the tool position in the toolbar, or NOT_FOUND if the tool is not found. GetToolPos() function only takes toolId(ID of the tool in question, as passed 2 min read
- wxPython | GetToolPacking() function in python In this article we are going to learn about GetToolPacking() function associated with wx.ToolBar class of wxPython. GetToolPacking() function simply returns the value used for packing tools.The packing is used for spacing in the vertical direction if the toolbar is horizontal, and for spacing in the 2 min read
- wxPython | GetToolEnabled() function in python In this article we are going to learn about GetToolEnabled() function present in class wx.ToolBar of wxPython. GetToolEnabled() function simply returns a pointer to the tool at particular position. It takes only single argument that is pos(position of tool starting from 0). Syntax : wx.ToolBar.GetTo 2 min read
- wxPython | GetToolBitmapSize() function in python In this article we are going to learn about GetToolBitmapSize() function of wxPython. GetToolBitmapSize() returns the size of bitmap that a toolbar expects to have. The default bitmap size is platform-dependent: for example, it is 16x15 for MSW and 24x24 for GTK. This size does not necessarily indic 2 min read
- wxPython | EnableTool() function in wxPython In this article we are going to learn about EnableTool() function of wx.ToolBar class of wxPython. It is another important function in wx.Toolbar class. EnableTool() function is used to enable or disable a particular tool in Toolbar. It takes 'enable' bool parameter which is when true enable the too 2 min read
- wxPython | GetMargins() function in python In this article we are going to learn about GetMargins() function of class wx.ToolBar in wxPython. GetMargins() function returns the left/right and top/bottom margins, which are also used for inter-toolspacing. GetMargins takes no parameters. Syntax: wx.ToolBar.GetMargins(self) Parameters: No Parame 2 min read
- wxPython - Frame() Constructor in Python In this article we will know about the frame() constructor in wxPython. frame() constructor is a constructor for the wx.Frame class of wxPython. This constructor is used to set different attributes of the frame. Syntax :  wx.Frame(parent, id=ID_ANY, title="", pos=DefaultPosition, size=DefaultSize, 1 min read