wxPython | EnableTool() function in wxPython (original) (raw)
Last Updated : 02 Mar, 2023
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 tool and disable it while it is false.
Syntax:
wx.toolbar.EnableTool(self, toolid, enable)
Parameters :
Parameter Input Type Description toolid int An integer by which the tool may be identified in subsequent operations. enable bool If True, enables the tool, otherwise disables it.
Code Example 1:
Python3
import
wx
class
Example(wx.Frame):
`` global
count
`` count
=
0
;
`` def
__init__(
self
,
*
args,
*
*
kwargs):
`` super
(Example,
self
).__init__(
*
args,
*
*
kwargs)
`` self
.InitUI()
`` def
InitUI(
self
):
`` self
.locale
=
wx.Locale(wx.LANGUAGE_ENGLISH)
`` pnl
=
wx.Panel(
self
)
`` self
.toolbar
=
self
.CreateToolBar()
`` rtool
=
self
.toolbar.AddTool(
13
,
'twoTool'
, wx.Bitmap(
'wrong.png'
), shortHelp
=
"Simple Tool2")
`` self
.toolbar.Realize()
`` self
.SetSize((
350
,
250
))
`` self
.SetTitle(
'Control'
)
`` self
.Centre()
`` self
.toolbar.EnableTool(
13
,
False
)
def
main():
`` app
=
wx.App()
`` ex
=
Example(
None
)
`` ex.Show()
`` app.MainLoop()
if
__name__
=
=
'__main__'
:
`` main()
Output Window: Code Example 2:
Python3
import
wx
class
Example(wx.Frame):
`` global
count
`` count
=
0
;
`` def
__init__(
self
,
*
args,
*
*
kwargs):
`` super
(Example,
self
).__init__(
*
args,
*
*
kwargs)
`` self
.InitUI()
`` def
InitUI(
self
):
`` self
.locale
=
wx.Locale(wx.LANGUAGE_ENGLISH)
`` pnl
=
wx.Panel(
self
)
`` self
.toolbar
=
self
.CreateToolBar()
`` rtool
=
self
.toolbar.AddTool(
13
,
'twoTool'
, wx.Bitmap(
'user.png'
), shortHelp
=
"Simple Tool2")
`` stool
=
self
.toolbar.AddTool(
14
,
'twoTool'
, wx.Bitmap(
'right.png'
), shortHelp
=
"Simple Tool2")
`` self
.toolbar.Realize()
`` self
.SetSize((
350
,
250
))
`` self
.SetTitle(
'Control'
)
`` self
.Centre()
`` self
.toolbar.EnableTool(
13
,
False
)
def
main():
`` app
=
wx.App()
`` ex
=
Example(
None
)
`` ex.Show()
`` app.MainLoop()
if
__name__
=
=
'__main__'
:
`` main()
Output Window:
Similar Reads
- wxPython | Exit() function in wxPython In this article we are going to learn about wx.Exit() which is a inbuilt parent function present in wxPython.Exit() function exits application after calling wx.App.OnExit . Should only be used in an emergency: normally the top-level frame should be deleted (after deleting all other frames) to termin 1 min read
- Python - AddCheckTool() function in wxPython In this article we are going to learn about AddCheckTool() in wx.ToolBar class of wxPython. AddCheckTool() function is used to add check tools. A checktool is a kind of toggle button. A checktool have a on and off state. Syntax : wx.ToolBar.AddCheckTool(self, toolId, label, bitmap1, bmpDisabled=Null 2 min read
- 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
- wxPython - EnableTool() function in wx.Toolbar In this article we are going to learn EnableTool() function of class wx.ToolBar of wxPython. EnableTool is used to enable or disable(make clickable and unclickable) the tool present in toolbar. Syntax : wx.ToolBar.EnableTool(self, toolid, enable) Parameters : ParameterInput TypeDescriptiontoolidintI 1 min read
- wxPython | FindControl() function in Python In this particular article we are going to learn about FindControl() function of wx.ToolBar class of wxPython. FindControl() function is used to returns a pointer to the control identified by id or None if no corresponding control is found. It takes only one parameter 'id'. Syntax : wx.ToolBar.FindC 2 min read
- wxPython| FindById() function in python In this article we are going to learn a simple function that is FindById() in wx.ToolBar class of wxPython. FindById is a simple function and returns a pointer to the tool identified by id or None if no corresponding tool is found. FindById() takes only single parameter that is id of a particular to 2 min read
- wxPython | CreateTool() function in wx.Toolbar In this particular article we are going to learn about CreateTool() function in wx.ToolBar class in wxPython. CreateTool() function is a factory function to create a new toolbar tool. CreateTool() function only creates a tool which is further added using AddTool() function. Syntax: wx.ToolBar.Create 2 min read
- wxPython - Enable() function in wx.MenuItem In this article we are going to learn about Enable() function associated with the wx.MenuItem class of wxPython. As the name Enable suggests Enable() function enables or disables the menu item. It only takes a boolean parameter enable, True for Enable and False for Disable. Syntax: wx.MenuItem.Enabl 1 min read
- wxPython | FindToolForPosition() function in python In this article we are going to learn about FindToolForPosition() function of class wx.ToolBar of wxPython. FindToolForPosition() is used to find a tool for the given mouse position. It takes x and y position of the window. Syntax: wx.ToolBar.FindToolForPosition(self, x, y) Parameters : ParameterInp 2 min read
- wxPython - DeleteTool() function in wx.ToolBar In this article we are going to learn about the DeleteTool() function of wx.ToolBar class of wxPython. DeleteTool() removes the specified tool from the toolbar and deletes it. It specifies a tool using a tool identifier. Syntax : wx.toolbar.DeleteTool(self, toolid) Returns: True if the tool was dele 1 min read