Flickering staticbox in sizer.

Hi

In my wx.python app I traverse over a dictionary with 3 keys. With 2 of the keys I create a wx.staticbox and wx.buttons set into their individual wx.StaticBoxSizers.
What I am seeing is that instead of 2 tracks being drawn, all three keys appear to Add to the sizer.
Note: When the program is executed, you can easily see the flickering by resizing the window. The first track will jump up and down like it belongs in two separate sizer positions.
I am sure it is just some logic error on my part but I have stepped through it so many times and cannot figure it out.

Also something that has been bothering me is when the SizerFlickerHelp.py app is closed it will crash python.exe. Excuse my lack of knowledge of wxPython, I am still exploring its vast depths. ;-D

I am running Python 2.6, with wxPython 2.8, on Windows XP.

Thanks

-Cort

SizerFlickerHelp.py (3.73 KB)

Hi Cort,

···

On Sep 9, 3:01 am, Cort Soest <cso...@gmail.com> wrote:

Hi

In my wx.python app I traverse over a dictionary with 3 keys. With 2 of
the keys I create a wx.staticbox and wx.buttons set into their individual
wx.StaticBoxSizers.
What I am seeing is that instead of 2 tracks being drawn, all three keys
appear to Add to the sizer.
Note: When the program is executed, you can easily see the flickering by
resizing the window. The first track will jump up and down like it belongs
in two separate sizer positions.
I am sure it is just some logic error on my part but I have stepped
through it so many times and cannot figure it out.

Also something that has been bothering me is when the SizerFlickerHelp.py
app is closed it will crash python.exe. Excuse my lack of knowledge of
wxPython, I am still exploring its vast depths. ;-D

I am running Python 2.6, with wxPython 2.8, on Windows XP.

Thanks

-Cort

I'm not able to replicate the flickering issue, but it does make
Python crash when I close the program. I did notice that if I resize
the frame, the top "track" doesn't refresh properly.

I am on Windows XP with wxPython 2.8.10.1 (msw-unicode), Python 2.5.2.
Maybe Robin et al will have some ideas...

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

Cort Soest wrote:

Hi

   In my wx.python app I traverse over a dictionary with 3 keys. With 2 of the keys I create a wx.staticbox and wx.buttons set into their individual wx.StaticBoxSizers.
    What I am seeing is that instead of 2 tracks being drawn, all three keys appear to Add to the sizer.
Note: When the program is executed, you can easily see the flickering by resizing the window. The first track will jump up and down like it belongs in two separate sizer positions.
    I am sure it is just some logic error on my part but I have stepped through it so many times and cannot figure it out.

Also something that has been bothering me is when the SizerFlickerHelp.py app is closed it will crash python.exe.

It is the same problem. Using the WIT (http://wiki.wxpython.org/Widget_Inspection_Tool) it is easy to see that there are two staticboxes, but there are three staticboxsizers added to the panel's sizer. So in other words, something is being added more than once and that is causing both problems you are seeing.

Take a look at the "for event..." loop in your code. At the bottom you are adding tracksizer to the ttysizer, but tracksizer is created inside the if statement. If that if statement is not executed then the value of tracksizer in the previous iteration of the loop is reused.

BTW, the WIT also shows that the width of the staticboxes is over 8000 pixels. Probably not what you wanted...

···

--
Robin Dunn
Software Craftsman

Thank you both for your responses, as always you guys are amazingly
quick to help and also incredibly knowledgeable about the subject!

Robin, as you mentioned the staticboxes are pretty wide. Their width
is essentially a time-line measured in deciseconds, which means that
the data set that you generated was around 80 seconds long. I've
already noticed how slow this can become, but do not know what
alternatives I have. My final intention would be to allow a data set
that is over an hour in length, which would create a static box of
over 36000 pixels in width... :frowning:

Any suggestions?

···

On Sep 9, 10:13 am, Robin Dunn <ro...@alldunn.com> wrote:

Cort Soest wrote:
> Hi

> In my wx.python app I traverse over a dictionary with 3 keys. With 2
> of the keys I create a wx.staticbox and wx.buttons set into their
> individual wx.StaticBoxSizers.
> What I am seeing is that instead of 2 tracks being drawn, all three
> keys appear to Add to the sizer.
> Note: When the program is executed, you can easily see the flickering by
> resizing the window. The first track will jump up and down like it
> belongs in two separate sizer positions.
> I am sure it is just some logic error on my part but I have stepped
> through it so many times and cannot figure it out.

> Also something that has been bothering me is when the
> SizerFlickerHelp.py app is closed it will crash python.exe.

It is the same problem. Using the WIT
(http://wiki.wxpython.org/Widget_Inspection_Tool) it is easy to see that
there are two staticboxes, but there are three staticboxsizers added to
the panel's sizer. So in other words, something is being added more
than once and that is causing both problems you are seeing.

Take a look at the "for event..." loop in your code. At the bottom you
are adding tracksizer to the ttysizer, but tracksizer is created inside
the if statement. If that if statement is not executed then the value
of tracksizer in the previous iteration of the loop is reused.

BTW, the WIT also shows that the width of the staticboxes is over 8000
pixels. Probably not what you wanted...

--
Robin Dunn
Software Craftsmanhttp://wxPython.org

Cort Soest wrote:

Thank you both for your responses, as always you guys are amazingly
quick to help and also incredibly knowledgeable about the subject!

Robin, as you mentioned the staticboxes are pretty wide. Their width
is essentially a time-line measured in deciseconds, which means that
the data set that you generated was around 80 seconds long. I've
already noticed how slow this can become, but do not know what
alternatives I have. My final intention would be to allow a data set
that is over an hour in length, which would create a static box of
over 36000 pixels in width... :frowning:

Any suggestions?

In general any time you have more data than can fit on the screen, or within a certain width, then the answer is to use scaling and/or scrolling. (For "scaling" think zoom-in and zoom-out.) In the specific case that you showed in your sample instead of making the widgets themselves be huge and scrolling the panel around I think I would keep the whole widget visible and just make it possible to scroll the data.

···

--
Robin Dunn
Software Craftsman