Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8930737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:57:45+00:00 2026-06-15T08:57:45+00:00

My wxPython project has a frame, with multiple nested sizers. One of the sizers

  • 0

My wxPython project has a frame, with multiple nested sizers.

One of the sizers contains a wxStaticImage with a bitmap that is read from a file.

I need the image to resize (grow/shrink) every time the frame is resized, so it will fit it’s sizer’s boundaries.

(I think that) I know how to resize an image. What I don’t know is how to:

  • how to get the image’s container’s width or height?
  • maybe i overlooked a property that does it auotmatically?

(for now, I don’t mind the proportions)

Edit: Complete solution

  1. i understood wrong about wxStaticBitmapin.Size. it does NOT describe the size of the image (i.e. image resolution), but rather – wxStaticBitmapin.Size gives the sizer’s slot dimentions, or in other words: the current widget’s size.

    so with Mik’s code i now how to fit into the slot.

  2. in addition to mike’s solution: when using onSize event on a frame, don’t forget to add event.skip(). otherwise the sizers will stop re-aligning. Altertanively, just use the image’s onSize.

here’s the complete event method:

def bitmap1_onSize(self, e=None):
    W, H = self.bitmap1.Size
    if W > H:
        NewW = W
        NewH = W * H / W
    else:
        NewH = H
        NewW = H * W / H
    img = wx.Image(self.frame_file_picker.Path, wx.BITMAP_TYPE_ANY)
    img = img.Scale(NewW,NewH)
    self.bitmap1.SetBitmap(wx.BitmapFromImage(img))
    e.Skip()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:57:46+00:00Added an answer on June 15, 2026 at 8:57 am

    You will need to catch EVT_SIZE or EVT_SIZING. You can check out this tutorial I wrote about creating an image viewer. It has some scaling code in it: http://www.blog.pythonlibrary.org/2010/03/26/creating-a-simple-photo-viewer-with-wxpython/

    I would just take that scaling code and use it to update your image. You’ll want to make sure you stop scaling your image up past its maximum size or you’ll end up with a lot of pixelization though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings all, I have a wxPython project (created with wxFormBuilder) that contains two panels,
in wxpython, is there a event that can occur when one of the function
I have a wxPython GUI application that contains 13 pairs of StaticText controls that
I have a wxPython application that relies on an external config file. I want
I am creating a Project Manager using wxPython it has a splitter window. On
I wrote a wxPython program that I am translating to wxWidgets. The program has
I've got a wxPython (via wxGlade) app with a dialog that has wx.MAXIMIZE_BOX set
I recently switched to wxPython 2.9 from 2.8. I ran one of my programs
I am new to wxPython. Can someone help me in: How to add multiple
Hi I am drawing a circle using wxpython for a project.Please look through the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.