Skip to content
Related Articles

Related Articles

wxPython – Show hidden Radio Box

Improve Article
Save Article
Like Article
  • Last Updated : 03 Jul, 2020

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.

Syntax: wx.RadioBox.Show(self, show=True)


ParameterInput TypeDescription
showboolif True shows the widget else if False hides it

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
    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
        # set size of frame
        self.SetSize((400, 250))
        # show output frame
    def onclick(self, e):
        # hide radio box from the frame
    def onclick1(self, e):
        # shows radio box
# wx App instance
ex = wx.App()
# Example instance
FrameUI(None, 'RadioButton and RadioBox')

Output Window:

before clicking button

after clicking button

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!