Unable to center mediactrl after resize

I am trying to display a MediaCtrl in the center of a frame after resizing it. The control is resized maintaining its aspect ratio to fit in the frame.

The resizing part is working perfectly, but re-positioning prove difficult. From the net, there were different suggestions, like resizing while the control is hidden. This didn’t work. calling the frame’s Layout() method doesn’t help either. The control’s initial position doesn’t change from its initial position before being resized.

The closest I got is the following:

  1. Create sizers. Do not call frame.SetSizer() yet. I only have a vert-sizer (outer) and horz-sizer (inner, centered).

  2. Create MediaCtrl with initial dimension (640, 480). Do not add control inside the sizer yet.

  3. Load/play media to get best size and finally resize the control.

  4. Add mediaCtrl to sizer. Below is how I do it:

    def successLoad(self, mediaCtrl):

     self.hbox.Add(mediaCtrl, flag=wx.CENTER)
    
     self.SetSizer(self.vbox)
    
     #self.Layout()
    

With the above code, the mediaCtrl is resized perfectly but the location is at (0, 0). I was hoping that by using sizers, the mediaCtrl will get centered automatically; it didn’t.

If I call Layout() method of the frame, the control is centered but the mediaCtrl size is somehow reset to its initial dimension (640, 480).

I feel that I am only one more function away, but I just cannot figure out what it is. Any help is appreciated.