[wxPython] Buggy Sizer behavior and static text wrapping

Michael Gilfix wrote:

  Hi all. I just discovered this behavior, which is making life rather
difficult: I have a sizer which contains a progress bar that I want
to display and hide multiple times within a panel. However, it's not
sufficient to just toggle the visibility of the item, because I really
want to be able to toggle the space around it as well.

  I was hoping to accomplish this using sizer.Prepend (osizer, 0, wxEXPAND)
and then use a sizer.Remove (osizer). This work great the first time and
then prompts the following:

Traceback (most recent call last):
  File "./libftpcube/ctrlwin.py", line 444, in onTimer
    t.updateTransferEstimate ()
  File "./libftpcube/ctrlwin.py", line 781, in updateTransferEstimate
    self.displayProgressBar ()
  File "./libftpcube/ctrlwin.py", line 763, in displayProgressBar
    self.sizer.Prepend (self.psizer, 0, wxEXPAND)
  File "/usr/local/lib/python2.2/site-packages/wxPython/sizers.py", line 227, in Prepend
    elif string.find(args[0].this, 'Sizer') != -1:
  File "/usr/local/lib/python2.2/site-packages/wxPython/wx.py", line 1636, in __getattr__
    raise wxPyDeadObjectError( self.attrStr % self._name )
wxPython.wx.wxPyDeadObjectError: The C++ part of the wxBoxSizer object has been deleted,
attribute access no longer allowed.

  In 2.3.2.1, this just causes wxPython to silently crash. Kind of
upsetting.

What's upsetting, that it no longer crashes and tells you exactly what the problem is?

  Another hopeful thing was the wxWindows documentation wxSizer.Show
() function. Unfortunately, this doesn't seem to be implemented in
wxPython. That's a shame because it would be really useful about
now.

It was only added about a week ago. It will be in CVS for wxPython too the next time I check in changes.

  My final thing is static text wrapping: I really wish there was some
kind of functionality that would wrap text within a given window. Has
anyone tackled this problem? I suppose I could take my message and
write a function to insert '\n' characters before assigning it to the
label. That would be sufficient for my purposes but ugly.

There was some talk about this on wx-dev not too long ago, but I don't remember what was decided. Once the archies are back up you might want to search there and find out.

···

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

> I was hoping to accomplish this using sizer.Prepend (osizer, 0, wxEXPAND)
>and then use a sizer.Remove (osizer). This work great the first time and
>then prompts the following:
>
>Traceback (most recent call last):
> File "./libftpcube/ctrlwin.py", line 444, in onTimer
> t.updateTransferEstimate ()
> File "./libftpcube/ctrlwin.py", line 781, in updateTransferEstimate
> self.displayProgressBar ()
> File "./libftpcube/ctrlwin.py", line 763, in displayProgressBar
> self.sizer.Prepend (self.psizer, 0, wxEXPAND)
> File "/usr/local/lib/python2.2/site-packages/wxPython/sizers.py", line
> 227, in Prepend
> elif string.find(args[0].this, 'Sizer') != -1:
> File "/usr/local/lib/python2.2/site-packages/wxPython/wx.py", line 1636,
> in __getattr__
> raise wxPyDeadObjectError( self.attrStr % self._name )
>wxPython.wx.wxPyDeadObjectError: The C++ part of the wxBoxSizer object has
>been deleted,
>attribute access no longer allowed.
>
> In 2.3.2.1, this just causes wxPython to silently crash. Kind of
>upsetting.

What's upsetting, that it no longer crashes and tells you exactly what
the problem is?

  Well, the fact that I can't rinse and repeat multiple times was a
little upsetting. But Alberto seems to have caught the problem, so
I'll investigate his solution this evening and use that for now. I guess
the Show function was added for that very reason... I'm not sure I want
to be on bleeding edge CVS at the moment. I imagine the next release is
quite a ways away..

>
> Another hopeful thing was the wxWindows documentation wxSizer.Show
>() function. Unfortunately, this doesn't seem to be implemented in
>wxPython. That's a shame because it would be really useful about
>now.

It was only added about a week ago. It will be in CVS for wxPython too
the next time I check in changes.

>
> My final thing is static text wrapping: I really wish there was some
>kind of functionality that would wrap text within a given window. Has
>anyone tackled this problem? I suppose I could take my message and
>write a function to insert '\n' characters before assigning it to the
>label. That would be sufficient for my purposes but ugly.
>

There was some talk about this on wx-dev not too long ago, but I don't
remember what was decided. Once the archies are back up you might want
to search there and find out.

  Will do. I'll head over there this weekend n' do some
searching. Would definitely be nice if the static text behaved like
the GtkText in this respect, and allow a style to resize the text
accordingly. I'll keep you guys posted on my findings.

                       -- Mike

P.S, I'm still working on the OS approval from the employer for the
colour chooser. It's a buracratic thing :slight_smile:

···

On Thu, Oct 31 @ 16:02, Robin Dunn wrote:

--
Michael Gilfix
mgilfix@eecs.tufts.edu

For my gpg public key:
http://www.eecs.tufts.edu/~mgilfix/contact.html