Resizing a wxPython Window
Question: Is it possible to make a wxPython window only re-sizable to a certain ratio? I
know you can disable resizing; however, I'd like it so when the window was
resized it stuck to a certain width to height ratio.


Answer: One obvious way to do this would be to bind `wx.EVT_SIZE` to a function that
constrains the aspect ratio. I'm not certain this is The Right Way to do this,
but it works:

    
    
    import wx
    
    class SizeEvent(wx.Frame):
        def __init__(self, parent, id, title):
            wx.Frame.__init__(self, parent, id, title)
    
            self.Bind(wx.EVT_SIZE, self.OnSize)
            self.Centre()
            self.SetSizeWH(400, 300)
            self.Show(True)
    
        def OnSize(self, event):
            hsize = event.GetSize()[0] * 0.75
            self.SetSizeHints(minW=-1, minH=hsize, maxH=hsize)
            self.SetTitle(str(event.GetSize()))
    
    app = wx.App()
    SizeEvent(None, 1, 'sizeevent.py')
    app.MainLoop()
    

(The boilerplate is borrowed from
[here](http://zetcode.com/wxpython/events/).)

