Resize while style=wx.SIMPLE_BORDER

The application should allow users to resize even when though there is no
border (wx.Frame init style=wx.SIMPLE_BORDER, FRAME_SHAPED, etc.).

no idea how you can let the user re-size a Frame with SIMPLE_BORDER set.
YOu may need to capture the mouse some other way to get the sizing events.

As you know, setting the background color (self.SetBackgroundColour(wx.TransparentColour))
is not supported on all platforms (works on OSX (see attached screenshot),
but not Linux).

I'm still not sure what that has to do with it.... don't you want your
Frame to fit your Window to fit teh contents? where does transparent come
in?

The goal is to allow the user to resize from x% to y% using the mouse from

a corner handle and resize while ensuring the image aspect ratio is
retained.

OK -- this I understand -- see the enclosed example (also here:
wxPythonDemos/AutoSizeBitmap.py at master · PythonCHB/wxPythonDemos · GitHub)

The trick is to catch the size event, then re-compute the size you want
that preserves the aspect ratio, then reset the size to that new size.

I spent quite a while fiddling around with it, 'till I hit on that it's the
Frame that's really doing the re-sizing -- so the re-size logic should be
in the Frame, and then it can re-size the Windows iwth te image in it.

The Image Window only needs to re-size the image to match its size...

Enjoy!

So in your case, you'll want to use similar logic in your top level fame,
and then pass the size into the Canvas.

-CHB

···

On Tue, Mar 14, 2017 at 5:01 PM, areich <alex@alexreich.com> wrote:

--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

oops, forgot the code…

(and you’ll need to point it to an image file on your system)

-CHB

AutoSizeBitmap.py (2.34 KB)

···

On Wed, Mar 15, 2017 at 4:00 PM, Chris Barker chris.barker@noaa.gov wrote:

On Tue, Mar 14, 2017 at 5:01 PM, areich alex@alexreich.com wrote:

The application should allow users to resize even when though there is no border (wx.Frame init style=wx.SIMPLE_BORDER, FRAME_SHAPED, etc.).

no idea how you can let the user re-size a Frame with SIMPLE_BORDER set. YOu may need to capture the mouse some other way to get the sizing events.

As you know, setting the background color (self.SetBackgroundColour(wx.TransparentColour)) is not supported on all platforms (works on OSX (see attached screenshot), but not Linux).

I’m still not sure what that has to do with it… don’t you want your Frame to fit your Window to fit teh contents? where does transparent come in?

The goal is to allow the user to resize from x% to y% using the mouse from a corner handle and resize while ensuring the image aspect ratio is retained.

OK – this I understand – see the enclosed example (also here: https://github.com/PythonCHB/wxPythonDemos/blob/master/AutoSizeBitmap.py)

The trick is to catch the size event, then re-compute the size you want that preserves the aspect ratio, then reset the size to that new size.

I spent quite a while fiddling around with it, 'till I hit on that it’s the Frame that’s really doing the re-sizing – so the re-size logic should be in the Frame, and then it can re-size the Windows iwth te image in it.

The Image Window only needs to re-size the image to match its size…

Enjoy!

So in your case, you’ll want to use similar logic in your top level fame, and then pass the size into the Canvas.

-CHB

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov