[wxpython-users] ExpandoTextCtrl issue
Jesse Aldridge
jessealdridge at gmail.com
Thu May 15 06:32:44 PDT 2008
I think there's a small bug in ExpandoTextCtrl, where the box doesn't get
expanded quite enough in some circumstances, as demonstrated below.
wxPython 2.8.7.1 (gtk2-unicode)
Ubuntu 8.04
---------------
import wx
import wx.lib.scrolledpanel as scrolledpanel
from wx.lib.expando import ExpandoTextCtrl
app =3D wx.App()
frame =3D wx.Frame(None, size=3D(1024,768), title=3D"Find and Replace")
frame_sizer =3D wx.BoxSizer(wx.VERTICAL)
frame.SetSizer(frame_sizer)
box =3D ExpandoTextCtrl(frame, value=3D"""
I'm having a problem with the ExpandoTextCtrl.
I think the problem occurs when I have several long lines in the text
control that get word-wrapped.
I get a scroll bar on the right.
I don't want a scroll bar, I want the box to expand to include all of the
text.
I suspect the problem is stemming from a bug in ExpandoTextCtrl that causes
the number of lines to be miscounted due to word wrapping.
It only seems to happen if the string is really long.
The program I'm working on is a Find and Replace tool.
It searches for a specified regex across several files.
Each file is output in an ExpandoTextCtrl with the match highlighted.
These text controls are expanded so they fill up the whole panel.
Most of them don't have scroll bars, but a few of them do.
The ones that do prevent me from being able to use the mouse wheel to scroll
through the entire column of text controls.
""")
box.SetMinSize((300,-1))
frame_sizer.Add(box)
frame.Show(True)
app.MainLoop()
---------------------
I was able to fix this by simply adding " + 1" to the line "numLines =3D
self.GetNumberOfLines()" in the _adjustCtrl method of ExpandoTextCtrl.
class ExpandoTextCtrl(wx.TextCtrl):
...
def _adjustCtrl(self):
# if the current number of lines is different than before
# then recalculate the size needed and readjust
numLines =3D self.GetNumberOfLines() + 1
...
...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200805=
15/a795f7fd/attachment.htm
More information about the wxpython-users
mailing list