Search code examples
pythonpython-2.7python-3.xwxpython

How to add wxpython frame style to disable frame resizing


I build a sample program using wxpython and i need to disable frame resizing.

I know i should use wx.Frame style but i don't know where i can add this in my code.

style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER

Code:

class Example(wx.Frame):
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
        self.AppUI()

    def AppUI(self):

        panel = wx.Panel(self)
        sizer = wx.GridBagSizer(5, 5)
        logo = wx.StaticBitmap(panel, bitmap=wx.Bitmap('./logo.png'))
        sizer.Add(logo, pos=(0, 2), flag=wx.TOP|wx.CENTER|wx.ALIGN_CENTER, border=3)
        line = wx.StaticLine(panel)
        sizer.Add(line, pos=(1, 0), span=(1, 5), flag=wx.EXPAND|wx.BOTTOM, border=10)

        # rest of code ........
        #.....
        #.....


        #app required
        self.SetSize((550, 560))
        self.SetTitle('Example App')
        self.Centre()
        self.SetSizer(sizer)
        self.Show(True)


def main():
    app = wx.App()
    Example(None)
    app.MainLoop()

if __name__ == '__main__':
    main()

Solution

  • I solve my problem by deleting **kwargs from init.

    class Example(wx.Frame):
        def __init__(self, *args, **kwargs):
            super(Example, self).__init__(*args, style=wx.MINIMIZE_BOX | wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx.CLIP_CHILDREN)
            self.AppUI()
    
            #rest of code....