wxPython – SetToolDisabledBitmap() function in wx.ToolBar
In this article, we are going to learn about SetToolDisabledBitmap() function associated with the wx.ToolBar class of wxPython. SetToolDisabledBitmap() function sets the bitmap to be used by the tool with the given ID when the tool is in a disabled state. This can only be used on Button tools, not controls. It takes two arguments id and bitmap.
Syntax:
wx.ToolBar.SetToolDisabledBitmap(Self, id, bitmap)
Parameters:
Parameter |
Input Type |
Description |
id |
int |
ID of the tool in question, as passed to AddTool . |
bitmap |
wx.Bitmap |
Bitmap to use for disabled tools. |
Code Example 1:
Python3
import wx
class Example(wx.Frame):
def __init__( self , * args, * * kwargs):
super (Example, self ).__init__( * args, * * kwargs)
self .InitUI()
def InitUI( self ):
self .locale = wx.Locale(wx.LANGUAGE_ENGLISH)
self .toolbar = self .CreateToolBar()
td = self .toolbar.AddTool( 1 , 'right' , wx.Bitmap( 'right.png' ))
self .toolbar.SetToolDisabledBitmap( id = 1 , bitmap = wx.Bitmap( 'wrong.png' ))
self .toolbar.Realize()
self .Bind(wx.EVT_TOOL, self .OnOne, td)
self .SetSize(( 350 , 250 ))
self .SetTitle( 'Undo redo' )
self .Centre()
def OnOne( self , e):
self .toolbar.EnableTool(toolId = 1 , enable = False )
self .toolbar.Realize()
def OnQuit( self , e):
self .Close()
def main():
app = wx.App()
ex = Example( None )
ex.Show()
app.MainLoop()
if __name__ = = '__main__' :
main()
|
Output:
Before clicking tick tool:
After clicking tick tool:
Last Updated :
05 Jan, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...