Skip to content
Related Articles

Related Articles

wxPython – Disable Button

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 18 Jun, 2020

In this article we are going to learn about how can we disable a button present in a frame. Sometimes when we dont want user to press a button we can disable a button and the button become unclickable.
In order to disable a button we can use Disable() function associated with wx.Button class of wxPython.

Syntax: wx.Button.Disable(Self)

Parameters: No parameters required in Disable() function.

Code Example:

import wx
class Example(wx.Frame):
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
    def InitUI(self):
        self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)
        self.pnl = wx.Panel(self)
        bmp = wx.Bitmap('download.jpg')
        # CREATE BUTTON AT POINT (20, 20) = wx.Button(self.pnl, id = 1, label ="Button", pos =(20, 20),
                                size =(100, 30),  name ="button")
        self.SetSize((350, 250))
def main():
    app = wx.App()
    ex = Example(None)
if __name__ == '__main__':

Output Image:

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!