wxPython: maximize Frame while disable resizing (Linux)

2k views Asked by At

On Linux, how do you disable re-sizing, but at the same time maximize the interface to begin with?

I have tried the following but it is not maximized:

style = wx.DEFAULT_FRAME_STYLE & ~wx.MAXIMIZE_BOX ^ wx.RESIZE_BORDER)

style = wx.MAXIMIZE | wx.DEFAULT_FRAME_STYLE & ~wx.MAXIMIZE_BOX ^ wx.RESIZE_BORDER

EDIT:

Tried Maximize() with resize disabled, still nothing. My versions: Linux, Python 2.4, wxPython 2.8.12.1

(style = wx.MAXIMIZE works for Windows, but not for Linux)

1

There are 1 answers

4
Mike Driscoll On

You're pretty close. You just forgot to call Maximize(). See below:

import wx

########################################################################
class NoResizeFrame(wx.Frame):
    """
    This frame cannot be resized. It can only be minimized, maximized
    and closed
    """

    #----------------------------------------------------------------------
    def __init__(self):
        """Constructor"""
        no_resize = wx.DEFAULT_FRAME_STYLE & ~ (wx.RESIZE_BORDER | 
                                                wx.RESIZE_BOX | 
                                                wx.MAXIMIZE_BOX)
        wx.Frame.__init__(self, None, title="No Resize", style=no_resize)
        panel = wx.Panel(self)

        self.Show()
        self.Maximize()

#----------------------------------------------------------------------
if __name__ == "__main__":
    app = wx.App(False)
    frame = NoResizeFrame()
    app.MainLoop()

You might find this tutorial of mine useful for better understanding frame style flags:

Or this slightly older tutorial on maximizing: