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

  • Home
  • SEARCH
  • 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 8861483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:30:07+00:00 2026-06-14T15:30:07+00:00

I want to know when a frame has been resized, so I can save

  • 0

I want to know when a frame has been resized, so I can save the size and remember it the next time the application launches. Here is my on_resize method:

def on_resize(self, event):
    logic.config_set('main_frame_size',
                     (event.Size.width, event.Size.height))

    event.Skip()

And it’s bound like this:

self.Bind(wx.EVT_SIZE, self.on_resize)

The problem is performance. For safety, my logic module saves the config file every time a setting changes, and writing the config file every time the resize event fires is way too performance taxing.

What would be the best/easiest way of monitoring for when the user is done resizing the frame?


Update

My config_set function:

def config_set(key, value):
    """Set a value to the config file."""
    vprint(2, 'Setting config value: "{}": "{}"'.format(key, value))

    config[key] = value

    # Save the config file.
    with open(config_file_path, 'w') as f:
        pickle.dump(config, f)
  • 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-14T15:30:09+00:00Added an answer on June 14, 2026 at 3:30 pm

    You could handle EVT_IDLE which is triggered when the event queue is empty:

    wx.IdleEvent: This class is used for EVT_IDLE events, which are generated and sent when the application becomes idle. In other words, the when the event queue becomes empty then idle events are sent to all windows (by default) and as long as none of them call RequestMore then there are no more idle events until after the system event queue has some normal events and then becomes empty again.

    The process of resizing or moving a window should keep the event queue jammed so it won’t become empty (and trigger the idle event) until the resizing/moving is done.

    Set a dirty flag in EVT_SIZE and check it in the EVT_IDLE handler. If the flag is set, save the new size and reset the flag:

    import wx
    
    class Frame(wx.Frame):
        def __init__(self):
            wx.Frame.__init__(self,None)
            self.resized = False # the dirty flag
            self.Bind(wx.EVT_SIZE,self.OnSize)
            self.Bind(wx.EVT_IDLE,self.OnIdle)
    
        def OnSize(self,event):
            self.resized = True # set dirty
    
        def OnIdle(self,event):
            if self.resized: 
                # take action if the dirty flag is set
                print "New size:", self.GetSize()
                self.resized = False # reset the flag
    
    app = wx.PySimpleApp()
    frame = Frame().Show()
    app.MainLoop()
    

    EVT_SIZE may also be triggered when restoring a minimized window (the window size remains the same). If you want to cut down on unnecessary saves, you may want to check if the size is actually different before you save it to the config (you could keep track of it in a variable containing the last saved size).

    You may want to add EVT_MOVE to keep track of the window position.

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

Sidebar

Related Questions

I know a similar question has been answered before here , but I just
I want to know if I can save a bitmap of the current viewport
i want know how i can manage multiple twitter account on iOS in my
This has been greatly bothering me in the past few weeks. In this time
I know this topic has been beaten into the ground, but I'm really stumped.
I have a few TextField s in my Frame . I want to know
I am sure this question has been asked but I can't find anything that
i want know if is possible, to get a specific element value of a
please help me. I want know about what types of flags to run an
I have an android app it displays web view.I want know the app idle

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.