I am trying to write an image control point selector function like MATLAB’s cpselect (http://www.mathworks.com/help/images/ref/cpselect.html) using wxPython. However, I have run into strange behavior that I do not understand. I have images inside a panel, and I would like the images to resize appropriately when the frame is resized. I call GetSize() on the frame, size the image equal to the panel size, and then update the wxBitmap. However, for some reason, the size return by GetSize is wrong the first time it is called. I have to set the bitmap and call it again to get the proper size. The attached code is the smallest subset I could create to recreate the problem.
When you run it, draw_image is called, and the panel size output to stdout is wrong. If you left-click on the image, a wx.EVT_LEFT_DOWN event calls draw_image again, and this time the panel size is correct. Then, when you click again and draw_image is called for a third time, the image is finally how it should be. I am not sure what is going on or if I am missing some sort of update statement so that the image is correct from the first call.
program.pyw (2.29 KB)