Re: [wxPython-users] Resize while style=wx.SIMPLE_BORDER

17 visningar
Hoppa till det första olästa meddelandet

Chris Barker

oläst,
15 mars 2017 19:01:082017-03-15
till wxpython-users
On Tue, Mar 14, 2017 at 5:01 PM, areich <al...@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....@noaa.gov

Chris Barker

oläst,
15 mars 2017 19:02:152017-03-15
till wxpython-users
oops, forgot the code....

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

-CHB

AutoSizeBitmap.py
Svara alla
Svara författaren
Vidarebefordra
0 nya meddelanden