Search code examples
wxpython

Change wx.Frame size inside class


I have created a wx.frame class with wxpython. I'd like to change the frame's size inside the class, is it possible? i know set the frame's size when init, like

class MyFrame(wx.Frame):
    def __init__(self):
        super(MyFrame,self).__init__(None, -1, title="demo", size=(width, height))
    def change_frame_size(self)

I'd like to create a function inside the class, which can change the frame's size to maximum. anybody knows?


Solution

  • SetSize method can be used to change the size of a window.

    def change_frame_size(self, width, height):
        self.SetSize(wx.Size(width, height))
    

    In order to maximize a window, you have Maximize method.

    self.Maximize()