Problem: When text is added to a wxTE_MULTILINE wxTextCtrl,
the control will vertically "blow out" of it's containing wxBoxSizer
when the parent window is resized.
This behavior is observed in Windows 2000 using:
ActivePython-2.3.5-236-win32-ix86
wxPython2.6-win32-ansi-2.6.1.0-py23.
It is not observed in Linux:
libwxgtku2.6-2.6.1-1mdk
libwxPythonGTK2.6-2.6.1.0-1mdk
wxPythonGTK-2.6.1.0-1mdk
wxGTK2.6-2.6.1-1mdk
python-egenix-mx-base-2.0.6-1mdk
python-base-2.4.1-3mdk
python-numeric-24.0-1mdk
libpython2.4-2.4.1-3mdk
libwxPythonGTK2.6-2.6.1.0-1mdk
wxPythonGTK-2.6.1.0-1mdk
python-2.4.1-3mdk
I know this is somewhat apples and oranges, but I'm stuck with Python 2.3
on Windows at the moment till I can find a pyPgSQL build for 2.4 on
windows - or a suitable alternative.
I am working on making a small test case, but I am also working
on keeping an irate customer happy, so for now, I can offer some
clues and hope they ring a bell for someone.
Some data:
The wxTextCtrl(s) in question is invoked from a class suggested by R Dunn and
poorly implemented by me - see class LabelText below. Note that the
wxTextCtrl is not sized - the "surrounding" wxPanel is sized as
wxSize( -1, howerevertallIwantit ) - don't know if this is relevant,
but in the interest of completeness...
The "blowout" seems to be purely vertical. It also seems to be limited
to about ten lines of text, beyond which the control will scroll vertically
- In different places of my code, I have the vertical size set to about 3-5
lines of text. Prior to 2.6.10, I was using wxPythonWIN32-2.5.1.5-Py23.
I know, I've slept through a couple of revisions, so I can't pinpoint where
this behavior started.
The "blowout" does not occur when the text is added - I see a wxTextCtrl the
size I specified after adding data, and can scroll through all ef it.
The "blowout" does not occur with empty wxTextCtrls. The window can be
resized on a panel containing an empty wxTextCtrl with no problems.
The "blowout" only occurs after adding a bunch of text, and resizing the
window.
More weirdness - the "blowout" can overlay or underlay controls placed
below it - somewhat surprising to me - I've seen controls pushed
out of place, but not overlaid/underlaid (unless I've forgotten to
manage a control and it piles up in the upper left corner
I've also tried "wrapping" it in a couple of wxBoxSizers with
contrasting orientation in an effort to control this behavior -
no luck - I've got a big block of commented-out code with
all of the permutations of myVerticalBox / MyHorizontalBox
Add ( 0/1, wxGROW / 0) to show for it. Basically, in many of these
cases, I don't want to grow the box vertically - I just want it
to sit politely at the size I set for it's parent wxPanel - but
the only way to avoid the "blowout" seems to be to allow vertical
growth - which, for me, has negative implications for the grids
lower in the screens. (They don't get enough room with the multiline
wxTextCtrls above them growing)
Again, this code used to work on Windows - it still works under
Linux. What changed?
Help? Thanks for wading through this.
Conrad
···
#_______________________________________________________________________________
LP_LEFT = 1
LP_RIGHT = 2
LP_TOP = 3
### Anything else is LP_BOTTOM - not used
### class for label + text with label position geometry mgmt per R Dunn suggestion in lists
### OK, it's rough, but til now, it does the job.
class LabelText( wxPanel ):
def __init__( self, parent, id, txt_id, psize, tstyle = wxTE_PROCESS_ENTER, title = '', defaulttxt= '', label_pos = LP_LEFT ):
wxPanel.__init__( self, parent, id, size = psize, style = wxSIMPLE_BORDER | wxTAB_TRAVERSAL)
# weird problem that cropped up in latest wxPython - crashes
# when wxTE_MULTILINE and wxTE_PROCESS_ENTER are both set
# update: not so weird now - new? error msg - multiline is ALWAYS process_enter
if not tstyle & wxTE_MULTILINE: tstyle = tstyle | wxTE_PROCESS_ENTER
# save reference to label and text field in class instance
self.fTxt = wxTextCtrl( self, txt_id, defaulttxt, style = tstyle )
self.fLab = wxStaticText( self, -1, ' ' + title + ' ' )
self.fTxt.SetFont(wxFont(14, wxROMAN, wxNORMAL, wxNORMAL)) # not very GP, maybe add font set later
if ( label_pos == LP_LEFT ) or ( label_pos == LP_RIGHT ):
self.box = wxBoxSizer( wxHORIZONTAL )
else:
self.box = wxBoxSizer( wxVERTICAL )
if ( label_pos == LP_LEFT ) or ( label_pos == LP_TOP):
self.box.Add( self.fLab, 0, wxLEFT | wxALIGN_CENTER_VERTICAL )
self.box.Add( self.fTxt, 1, wxEXPAND )
else:
self.box.Add( self.fTxt, 1, wxEXPAND )
self.box.Add( self.fLab, 0, wxLEFT | wxALIGN_CENTER_VERTICAL )
self.set_txt_bg( TxtDefaultBGColor )
self.set_lab_bg( LabelDefaultBGColor )
self.SetAutoLayout( True )
self.SetSizer( self.box )
#_______________________