Friday, September 26, 2025
HomeLanguageswxPython – Get size of Radio Button Window

wxPython – Get size of Radio Button Window

In this article we are going to learn that how can we get the size of Radio button window present in the frame. In order to do this we will use GetSize() function associated with wx.RadioButton class of wxPython. GetSize() function simply returns the size of the radio button in pixels. GetSize() function require no arguments.

Syntax: wx.RadioButton.GetSize(self) Parameters: GetSize() function require no arguments. Return Type: wx.Size Returns: Returns the size of the radio button

Code Example: 

Python3




import wx
 
APP_EXIT = 1
 
 
class Example(wx.Frame):
 
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
 
        self.InitUI()
 
    def InitUI(self):
        self.pnl = wx.Panel(self)
         
        # create radio button at position (30, 10)
        self.rb1 = wx.RadioButton(self.pnl, label ='Btn1',
                             pos =(30, 10), size =(100, 20))
 
        # change background colour
        self.rb1.SetBackgroundColour((255, 100, 255, 255))
 
        # change size to (300, 50)
        self.rb1.SetSize((300, 50))
 
        # print size of radio button
        print(self.rb1.GetSize())
 
 
def main():
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
 
 
if __name__ == '__main__':
    main()


Console Output:

(300, 50)

Output Window:

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32320 POSTS0 COMMENTS
Milvus
84 POSTS0 COMMENTS
Nango Kala
6683 POSTS0 COMMENTS
Nicole Veronica
11854 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11910 POSTS0 COMMENTS
Shaida Kate Naidoo
6795 POSTS0 COMMENTS
Ted Musemwa
7071 POSTS0 COMMENTS
Thapelo Manthata
6756 POSTS0 COMMENTS
Umr Jansen
6762 POSTS0 COMMENTS