Sunday, November 17, 2024
Google search engine
HomeLanguageswxPython – RadioGroups in wx.ToolBar

wxPython – RadioGroups in wx.ToolBar

In this article we are going to learn how can we create RadioGroups in Toolbar. In Radiogroups different RadioMenus consist different RadioTools. In a particular RadioMenu if we click any RadioTool it gets chosen and other RadioTools gets unchosen automatically.

Steps:

1. We will create two Radio Tools.
2. After creating these tools a Separator is created.
3. After creating Separator we will create other two Radio tools.
4. After following these steps we will get two Radio Menus.

Syntax :

various Radio Tools{Radio Menu}
Add Separator
various Radio Tools{Radio Menu}
Code Example:




import wx
  
  
class Example(wx.Frame):
    global count
    count = 0;
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
  
        self.InitUI()
  
    def InitUI(self):
        pnl = wx.Panel(self)
        self.toolbar = self.CreateToolBar()
  
        # Radio Tools
        ptool = self.toolbar.AddRadioTool(12, 'right', wx.Bitmap('/home/wxPython/right.png'),
                                                                     shortHelp ="Radio Tool")
  
        qtool = self.toolbar.AddRadioTool(13, 'right2', wx.Bitmap('/home/wxPython/wrong.png'),
                                                                     shortHelp ="Radio Tool")
        # Toolbar Separator 
        self.toolbar.AddSeparator()
  
        # Radio Tools
        rtool = self.toolbar.AddRadioTool(12, 'right', wx.Bitmap('/home/wxPython/right.png'), 
                                                                     shortHelp ="Radio Tool")
  
        stool = self.toolbar.AddRadioTool(13, 'right2', wx.Bitmap('/home/wxPython/wrong.png'),
                                                                     shortHelp ="Radio Tool")
        self.toolbar.Realize()
        self.SetSize((350, 250))
        self.SetTitle('Control')
        self.Centre()
          
  
  
def main():
  
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
  
  
if __name__ == '__main__':
    main()


Output :

Last Updated :
17 May, 2020
Like Article
Save Article

<!–

–>

Similar Reads
Related Tutorials
Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments