user825286
user825286

Reputation:

wxPython Disable Frame Resizing

How can I disable a wxFrame from being resized by the user? If there's a flag to put in when creating the frame, what is it?

Upvotes: 12

Views: 17576

Answers (3)

user1766438
user1766438

Reputation: 582

I tried the suggestion above using this program:

import wx

app = wx.App()
frame = wx.Frame(None, style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER)
frame.Show()
app.MainLoop()

...but it didn't work. The frame still remains resizable.

Replacing the style value with this "wx.DEFAULT_FRAME_STYLE & (~wx.RESIZE_BORDER)" didn't work either. The frame was still resizable.

Using SetMaxSize() and SetMinSize() does prevent resizing, but the resize arrows still appear on Mac OS X.

Example:

import wx

app = wx.App()
frame = wx.Frame(None, size=(400,300))
frame.SetMaxSize(wx.Size(400,300))
frame.SetMinSize(wx.Size(400,300))
frame.Show()
app.MainLoop()

3-20-2019 update:
https://wxpython.org/Phoenix/docs/html/wx.Frame.html
According to this page to disable frame resizing use this:

style = wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX)

Using this example program I was able to make the resize arrows completely disappear on Mac OS 10.12:

import wx

app = wx.App()
frame = wx.Frame(None, style = wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX))
frame.Show()
app.MainLoop()

Upvotes: 7

Wolfger
Wolfger

Reputation: 191

You can use SetSizeHints (or SetMaxSize and SetMinSize) to restrict the maximum and minimum sizes or th

Upvotes: 1

Cédric Julien
Cédric Julien

Reputation: 80761

The default window style is wx.MINIMIZE_BOX | wx.MAXIMIZE_BOX | wx.RESIZE_BORDER | wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx.CLIP_CHILDREN

If you remove wx.RESIZE_BORDER from it, you'll get a frame which cannot be resized.

Something like this should do the stuff :

wx.Frame(parent, style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER)

Upvotes: 20

Related Questions