Movatterモバイル変換


[0]ホーム

URL:


Open In App
Next Article:
wxPython - GetLabel() function in wx.Button
Next article icon
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: boolReturns: 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==
importwxclassExample(wx.Frame):def__init__(self,*args,**kwargs):super(Example,self).__init__(*args,**kwargs)self.InitUI()defInitUI(self):self.locale=wx.Locale(wx.LANGUAGE_ENGLISH)# create parent panelself.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 destroyself.btn0=wx.Button(self.pnl,id=1,label="Click button to remove",pos=(20,20))# bind Onclick() function with buttonself.btn1.Bind(wx.EVT_BUTTON,self.Onclick)self.SetSize((350,250))self.SetTitle('wx.Button')self.Centre()defOnclick(self,e):# destroy btn0 buttonself.btn0.Destroy()defmain():app=wx.App()ex=Example(None)ex.Show()app.MainLoop()if__name__=='__main__':main()
Output Window:before Destroy()after Destroy()

Similar Reads

We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood ourCookie Policy &Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences

[8]ページ先頭

©2009-2025 Movatter.jp