Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

wxPython | GetToolEnabled() function in python

  • Last Updated : 04 Jun, 2020

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.GetToolEnabled(self, toolid)

Parameter :

ParameterInput TypeDescription
toolidintID of the tool in question, as passed to AddTool .

Return Type:

True if the tool is enabled, False otherwise.

Code Example:




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()
        self.toolbar.SetMargins(10, 10)
        # Add Tools Using AddTool function
        rtool = self.toolbar.AddTool(13, 'Toolone', wx.Bitmap('wrong.png'), shortHelp ="Simple Tool2")
        stool = self.toolbar.AddTool(14, 'Tooltwo', wx.Bitmap('wrong.png'), shortHelp ="Simple Tool")
  
        self.toolbar.Realize()
        self.SetSize((350, 250))
        self.SetTitle('Control')
        self.Centre()
  
        bl = self.toolbar.GetToolEnabled(13)
  
        # print True of enabled
        print(bl)
  
  
def main():
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
  
  
if __name__ == '__main__':
    main()

Output:

True

Code Example:




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()
        self.toolbar.SetMargins(10, 10)
        # Add Tools Using AddTool function
        rtool = self.toolbar.AddTool(13, 'Toolone', wx.Bitmap('wrong.png'), shortHelp ="Simple Tool2")
        stool = self.toolbar.AddTool(14, 'Tooltwo', wx.Bitmap('wrong.png'), shortHelp ="Simple Tool")
        self.toolbar.Realize()
        self.toolbar.EnableTool(14, False)
        self.SetSize((350, 250))
        self.SetTitle('Control')
        self.Centre()
  
        bl = self.toolbar.GetToolEnabled(14)
  
        # print True of enabled
        print(bl)
  
  
def main():
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
  
  
if __name__ == '__main__':
    main()

Output:

False

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!