[wxPython] wxscrolledwindow problem + sample (functional but useless) code

Hi there,

What I'm trying to do:
I've got an image which I want to rescale, while keeping its aspect ratio. That means that if I have a square window and a rectangular (w > h) image, the image is scaled on window resizing so that the height of the scaled image is now the height of the new window, and a scroll bar appears at the bottom of the window, because the image doesn't fit entirely in the window (if not clear, run my code, but change IMAGE_PATH otherwise it looks for the demo image.bmp at the root directory)

The Problem: When resizing the window to an aspect ratio different from the image aspect ratio, everything is fine, but when the aspect ratio is the same and both scrollbars disapear, some weird shit happens: the image flickers like hell and the programs dies 9 times out of 10 :slight_smile:
I use GetClientSize() to rescale the image, however the function does not return the size the window would have WITHOUT the scrollbars.

Any idea or comment?

Also, why can't I switch properly (file menu) from notebook to splitter view? should I go through a wxpanel instead of directly using MyFrame.win?
any chance of being able to swich from splitter to notebook to MDI without recreating MyCanvas windows?

Oh! and my code which is absolutely useless is at best public domain, at worse (from having taken code from other programs) opensource :wink:

Cheers,
Egor

/ (8.16 KB)

···

--

_______________________________________________
Talk More, Pay Less with Net2Phone Direct(R), up to 1500 minutes free!
http://www.net2phone.com/cgi-bin/link.cgi?143

The Problem: When resizing the window to an aspect ratio different from

the image aspect ratio, everything is fine, but when the aspect ratio is the
same and both scrollbars disapear, some weird shit happens: the image
flickers like hell and the programs dies 9 times out of 10 :slight_smile:

I use GetClientSize() to rescale the image, however the function does not

return the size the window would have WITHOUT the scrollbars.

You're getting recursive calls to OnResize. Putting a guard condition in
place helps a lot:

    def OnResize(self,event):
        if self.in_resize:
            return
        self.in_resize = true

        ... the rest of it

        self.in_resize = false

Also, you shouldn't need a call to DoDrawing in OnResize as the size event
should be followed by a paint event anyway.

Any idea or comment?

Also, why can't I switch properly (file menu) from notebook to splitter

view? should I go through a wxpanel instead of directly using MyFrame.win?

any chance of being able to swich from splitter to notebook to MDI without

recreating MyCanvas windows?

Have you tried the wxWindow.Reparent method?

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!