wxPython - Destroy button widget using Destroy() function Last Updated : 26 Jun, 2020 Comments Improve Suggest changes Like Article Like Report In this article we will learn that, how can we destroy a button widget from a window using Destroy() function in wx.Button class of wxPython. Destroy() function is used to simply destroy a window or widget safely. Destroy() returns True if the window has either been successfully deleted, or it has been added to the list of windows pending real deletion. Syntax: wx.StaticText.Destroy(self) Parameters: Destroy() function takes no arguments. Return Type: bool Returns: True if the window has either been successfully deleted, or it has been added to the list of windows pending real deletion. Code Example: Python3 1== 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) # create parent panel self.pnl = wx.Panel(self) # create a button at point (20, 50) self.btn1 = wx.Button(self.pnl, id = 1, label ="Remove Text", pos =(20, 50)) # create button to destroy self.btn0 = wx.Button(self.pnl, id = 1, label ="Click button to remove", pos =(20, 20)) # bind Onclick() function with button self.btn1.Bind(wx.EVT_BUTTON, self.Onclick) self.SetSize((350, 250)) self.SetTitle('wx.Button') self.Centre() def Onclick(self, e): # destroy btn0 button self.btn0.Destroy() def main(): app = wx.App() ex = Example(None) ex.Show() app.MainLoop() if __name__ == '__main__': main() Output Window: before Destroy() after Destroy() Comment More infoAdvertise with us Next Article wxPython - Destroy button widget using Destroy() function R RahulSabharwal Follow Improve Article Tags : Python Python-gui Python-wxPython Python wxPython-Button Practice Tags : python Similar Reads wxPython - Create() function in wx.Button In this article we are going to learn about Create() function associated with wx.Button class of wxPython. Create() function is used for button creation function for two-step creation. It takes attributes of a button as arguments. Syntax: wx.Button.Create(self, parent, id=ID_ANY, label="", pos=Defau 1 min read wxPython - Create Radio Button using Create() function Create() function is used for the two-step construction of Radio Button in wxPython. Create() function takes different attributes of radio button as an argument Syntax:  wx.RadioButton.Create(parent, id=ID_ANY, label="", pos=DefaultPosition, size=DefaultSize, style=0, validator=DefaultValidator, nam 1 min read wxPython - SetDefault() function in wx.Button In this article we are going to learn about SetDefault() function associated with the wx.Button class of wxPython. This sets the button to be the default item in its top-level window (e.g. the panel or the dialog box containing it). As normal, pressing return causes the default button to be depresse 1 min read wxPython - SetLabel() function in wx.Button In this article we are going to learn about SetLabel() function associated with wx.Button class of wxPython. SetLabel() function is used to set the string label for the button. It takes a string parameter that is used as label for button. Syntax: wx.Button.SetLabel(self, label) Parameters: Parameter 1 min read wxPython - GetLabel() function in wx.Button In this article, we are going to learn about GetLabel() function associated with wx.Button class of wxPython. GetLabel() function is used to return the string label for the button. No parameters are required by GetLabel() function. Syntax: wx.Button.GetLabel(self) Parameters: No parameters are requi 1 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 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 wxPython | DeleteToolByPos() function in wx.ToolBar In this article we are going to learn about DeleteToolByPos() function of wx.ToolBar class of wxPython. DeleteToolByPos() removes the specified tool from the toolbar and deletes it. Only difference between DeleteTool() and DeleteToolByPos() function is that DeleteToolByPos() specifies tool by its in 1 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 - Change labels using button In this article we are going to learn how to make button interactive with the frame. In this article we will change the text label on the pressing button. So let's start with the steps. Step 1: Create a static text on the frame. Step 2: Add button to the frame. Step 3: Create event function for the 1 min read Like