In this article we are going to learn how can we hide the whole Radio Box widget present inside a frame. In order to do that we will be using Hide() function. Hide() function requires no parameters. Hide() function only hides the Radio Box widget while not remove from the window. Also, the value of items inside Radio Box remain unchanged.
Syntax: wx.RadioBox.Hide(self)
Parameters Hide() function requires no parameters.
Return Type: bool
Code Example:
import wx
class FrameUI(wx.Frame):
def __init__( self , parent, title):
super (FrameUI, self ).__init__(parent, title = title, size = ( 300 , 200 ))
# function for in-frame components
self .InitUI()
def InitUI( self ):
# parent panel for radio box
pnl = wx.Panel( self )
# list of choices
lblList = [ 'Radio One' , 'Radio Two' ]
# create radio box containing above list
self .rbox = wx.RadioBox(pnl, label = 'RadioBox' , pos = ( 80 , 10 ), choices = lblList,
majorDimension = 1 , style = wx.RA_SPECIFY_ROWS)
# create a button in the frame
self .btn = wx.Button(pnl, 1 , "Hide RadioBox" , pos = ( 100 , 100 ));
# bind a function with button
self .btn.Bind(wx.EVT_BUTTON, self .onclick)
# set frame in centre
self .Centre()
# set size of frame
self .SetSize(( 400 , 250 ))
# show output frame
self .Show( True )
def onclick( self , e):
# hide radio box from the frame
self .rbox.Hide()
# wx App instance ex = wx.App()
# Example instance FrameUI( None , 'RadioButton and RadioBox' )
ex.MainLoop() |
Output Window:
before clicking button
after clicking button