Q:

Fixed canvas shape in wxpython ogl library

I am making a small program to draw segments in python using wxpython and ogl library. I have created and added the canvas to a sizer, but am unable to freeze the size of the canvas. 
sizer = wx.BoxSizer(wx.VERTICAL)
canvas_sizer = wx.BoxSizer(wx.HORIZONTAL)
text_sizer = wx.BoxSizer(wx.HORIZONTAL)
stat = wx.StaticText(panel,-1,'position')

canvas = ogl.ShapeCanvas(panel)
diagram = ogl.Diagram()
canvas.SetDiagram(diagram)
diagram.SetCanvas(canvas)

canvas_sizer.Add(canvas,1,wx.GROW)
text_sizer.Add(stat,1,wx.ALL,5)
sizer.Add(canvas_sizer,1,wx.GROW)
sizer.Add(text_sizer)

self.SetSizer(sizer)
sizer.Fit(self)

The above code is part of my actual code. Please suggest ways to make the canvas size fixed

A:

You must set the proportion the slot must occupy to 0 and to give the contents a minimum size in case it is required:
sizer = wx.BoxSizer(wx.VERTICAL)
text_sizer = wx.BoxSizer(wx.HORIZONTAL)
canvas_sizer = wx.BoxSizer(wx.HORIZONTAL)
stat = wx.StaticText(self, -1, "position")

# for testing I used a panel instead of your ogl object
canvas = wx.Panel(self, -1)    
canvas.SetMinSize((-1, 70))     # Needed here to give a min size to panel,
                                # otherwise the panel would not be seen.
                                # The sizer will occupy the minimal 
                                # to hold its contents.

canvas_sizer.Add(canvas, 1, wx.EXPAND, 0)
sizer.Add(canvas_sizer, 0, wx.EXPAND, 0)   # <- note proportion 0 here
text_sizer.Add(stat, 1, wx.EXPAND, 0)
sizer.Add(text_sizer, 1, wx.EXPAND, 0)
self.SetSizer(sizer)
sizer.Fit(self)
self.Layout()

