HomeLanguageswxPython – GetDefaultSize() function in wx.Button

wxPython – GetDefaultSize() function in wx.Button

In this article we are going to learn about GetDefaultSize() function associated with wx.Button class of wxPython. GetDefaultSize() function is used to return the default size for the buttons.

It is advised to make all the dialog buttons of the same size and this function allows retrieving the (platform, and current font dependent) size which should be the best suited for this.

Syntax: wx.Button.GetDefaultSize(win=None)

Parameters:

Parameter Input Type Description
win wx.Window Parent Window.

Return Type: wx.Size

Code Example:




import wx
  
  
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)
        self.btn = wx.Button(self.pnl, label ='Button', 
                             pos =(20, 20), size =(100, 20))
  
        # GET DEFAULT SIZE
        s = self.btn.GetDefaultSize(self)
        # PRINT DEFAULT SIZE
        print(s)
  
        self.SetSize((350, 250))
        self.SetTitle('wx.Button')
        self.Centre()
  
def main():
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
  
  
if __name__ == '__main__':
    main()


Console Output:

(88, 26)

Output Window:

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

Most Popular

Dominic
32686 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
7053 POSTS0 COMMENTS
Nicole Veronica
12194 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12291 POSTS0 COMMENTS
Shaida Kate Naidoo
7179 POSTS0 COMMENTS
Ted Musemwa
7444 POSTS0 COMMENTS
Thapelo Manthata
7157 POSTS0 COMMENTS
Umr Jansen
7147 POSTS0 COMMENTS