Forcing the position of scroll bars on a wxTextCtrl
Andrea Gavana
andrea_gavana at tin.it
Thu Nov 3 14:53:36 EST 2005
Hello Clans,
as a first suggestion, it is usually recommended that you post a small
*working* sample, in order to help others in understanding the problem and
also to give others the possibility to test your code. Noting that I am not
able to run your code as it is, I can just speculate one suggestion:
> Calling SetScrollPos( GetScrollRange() ) sets the scrollbar slider to
> the correct position, but *doesn't update the text in the window* :(
This is because SetScrollPos only affects scrollbars, not the wx.TextCtrl
itself. What happens if you add a self._ctrl.Refresh() after the
SetScrollPos() call? Something like:
class LogControl:
""" Simple helper to redirect stdout to a panel in the GUI """
def __init__( self, textCtrl ):
self._ctrl = textCtrl
self._log = ""
self.write( "Application Started...\n" )
def write( self, Message ):
self._log = self._log + Message
self._ctrl.SetValue( self._log )
# Force scroll bars to end of window - does not update text in
control!
self._ctrl.SetScrollPos(wx.VERTICAL, self._ctrl.GetScrollRange(
wx.VERTICAL))
self._ctrl.Refresh()
I also suggest that you use AppendText() instead of the bunch of calls to
write(). Something along the lines (untested code!!!):
class LogControl:
""" Simple helper to redirect stdout to a panel in the GUI """
def __init__( self, textCtrl ):
self._ctrl = textCtrl
self._log = ""
self.write( "Application Started...\n" )
def write( self, Message ):
self._log = self._log + Message
self._ctrl.AppendText( self._log )
# Force scroll bars to end of window - does not update text in control!
# self._ctrl.SetScrollPos(wx.VERTICAL, self._ctrl.GetScrollRange(
wx.VERTICAL))
# self._ctrl.Refresh()
HTH.
Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77
More information about the Python-list
mailing list