In this article we will learn how can we show the hidden Radio Box present in the frame. In order to do that we will use Show() method. Show() method can be used for both hide as well as show a widget.
Show takes a boolean argument show, which if True shows the widget else hides it.
Python3 1==
Output Window:
before clicking button
after clicking button
Syntax: wx.RadioBox.Show(self, show=True) ParametersCode Example:Return Type: bool
Parameter Input Type Description show bool if True shows the widget else if False hides it
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 =(125, 100));
# create a button in the frame
self.btn1 = wx.Button(pnl, 2, "Show RadioBox", pos =(125, 150));
# bind a function with button btn
self.btn.Bind(wx.EVT_BUTTON, self.onclick)
# bind a function with button btn1
self.btn1.Bind(wx.EVT_BUTTON, self.onclick1)
# 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.Show(False)
def onclick1(self, e):
# shows radio box
self.rbox.Show()
# wx App instance
ex = wx.App()
# Example instance
FrameUI(None, 'RadioButton and RadioBox')
ex.MainLoop()
before clicking button
after clicking button