Greetings!
I'm trying to create an input field that will grow as more text is typed
in. I don't want a scrollbar, but I want the control to get bigger and
take up more of the screen as more text is entered. Enclosed is a
program that does this, sort of. When the vertical length gets to about
140 pixels, it stops growing. Does anyone know why this is occurring?
Is it a problem with TextCtrl?
Thanks!
Billy Earney
MyTextCtrl.py (1.58 KB)
Change you OnKeyPressed method like this:
def OnKeyPressed(self, event):
__x, __y = self.GetTextExtent(self.GetValue())
# Some more extra space.
__x += 18
__y += 18
self.size = (__x, __y)
self.AdjustSize()
event.Skip()
···
On Mon, 2005-08-15 at 10:51 -0500, Earney, Billy C. wrote:
Greetings!
I'm trying to create an input field that will grow as more text is typed
in. I don't want a scrollbar, but I want the control to get bigger and
take up more of the screen as more text is entered. Enclosed is a
program that does this, sort of. When the vertical length gets to about
140 pixels, it stops growing. Does anyone know why this is occurring?
Is it a problem with TextCtrl?
Earney, Billy C. wrote:
I'm trying to create an input field that will grow as more text is typed
in. I don't want a scrollbar, but I want the control to get bigger and
take up more of the screen as more text is entered. Enclosed is a
program that does this, sort of. When the vertical length gets to about
140 pixels, it stops growing. Does anyone know why this is occurring?
Is it a problem with TextCtrl?
I don't think GetBestSize() is helping in this case. Try this code, which determines the height based on the number of hard line returns (may not be what you want because word-wrapping isn't accounted for):
def OnKeyPressed(self, event):
charHeight = self.GetCharHeight()
numLines = len(self.GetValue().split('\n')) + 1
bestHeight = charHeight * numLines
if self.size[1] < bestHeight:
self.size[1] = bestHeight
self.AdjustSize()
event.Skip()
···
--
Paul McNett
http://paulmcnett.com