Reducing/eliminating flicker

Tim wrote:

I've got a choicebox that on selection, will show the corresponding sizer and hide all others in a list. To get the sizers to appear properly, I have to use "fit()" after I show or hide one. Here is the relevant code:

    def __queryChoiceEvent(self, event):
        choiceBox = event.GetEventObject()
        selectedChoice = choiceBox.GetStringSelection()

    # Hide all sizers
        for choice in self.choices.keys():
            self.userInputSizer.Hide(self.choices[choice]["sizer"], recursive=True)
            self.Fit()
        # Show the selected sizer
        self.userInputSizer.Show(self.choices[selectedChoice]["sizer"], recursive=True)

        self.Fit()

The problem is that the user can watch this happen. The GUI seems to update on each call to Fit(). Thus, the sizer shrinks, along with the whole dialog, and then the selected embedded sizer appears and the parent sizer increases to its original size, again along with the whole dialog.

You should only need the last Fit, not the one in the loop.

···

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