Disable auto scroll

Hi all,

I have redirected stdout and stderr to a RedirectText class that
contains a wxTextCtrl object as shown here:

class RedirectText(object):
    def __init__(self,aWxTextCtrl):
        self.out=aWxTextCtrl

    def write(self,string):
        wx.CallAfter(self.out.Freeze)
        wx.CallAfter(self.out.WriteText, string)
        wx.CallAfter(self.out.Thaw)

However, I'm having a hard time stopping the window from
auto-scrolling. What you see above is my attempt to stop it, but it
just doesn't work.
This really seems like it should be simpler (i.e. an option to be able to set).

Any ideas on how to do this?

Thanks!
Luke

Hi,

Hi all,

I have redirected stdout and stderr to a RedirectText class that
contains a wxTextCtrl object as shown here:

class RedirectText(object):
    def __init__(self,aWxTextCtrl):
        self.out=aWxTextCtrl

    def write(self,string):
        wx.CallAfter(self.out.Freeze)
        wx.CallAfter(self.out.WriteText, string)
        wx.CallAfter(self.out.Thaw)

However, I'm having a hard time stopping the window from
auto-scrolling. What you see above is my attempt to stop it, but it
just doesn't work.
This really seems like it should be simpler (i.e. an option to be able to set).

Any ideas on how to do this?

Freeze and Thaw only control the processing of Paint events and do
nothing else. Mostly usefully for grouping multiple screen update
calls into one to reduce flashing.

The WriteText method updates the insertion point which is what is
causing the scrolling (see documentation of WriteText
wxTextCtrl).

You may be able to work around this behavior by manipulating the
insertion point between the Freeze/Thaw and using AppendText (which
also moves the insertion point).

Other option is to use the StyledTextCtrl it is much more flexible in
these regards and has a more useful API for manipulating where/how
text is inserted in the buffer.

Cody

···

On Wed, Aug 22, 2012 at 1:52 PM, Luke Whitehorn <luke.whitehorn@yahoo.co.uk> wrote:

Thanks Cody. I’ll look into the StyledTextCtrl.

Luke

···

On Wednesday, 22 August 2012 20:13:17 UTC+1, Cody Precord wrote:

Hi,

On Wed, Aug 22, 2012 at 1:52 PM, Luke Whitehorn > > luke.wh...@yahoo.co.uk wrote:

Hi all,

I have redirected stdout and stderr to a RedirectText class that

contains a wxTextCtrl object as shown here:

class RedirectText(object):

def __init__(self,aWxTextCtrl):
    self.out=aWxTextCtrl
def write(self,string):
    wx.CallAfter(self.out.Freeze)
    wx.CallAfter(self.out.WriteText, string)
    wx.CallAfter(self.out.Thaw)

However, I’m having a hard time stopping the window from

auto-scrolling. What you see above is my attempt to stop it, but it

just doesn’t work.

This really seems like it should be simpler (i.e. an option to be able to set).

Any ideas on how to do this?

Freeze and Thaw only control the processing of Paint events and do

nothing else. Mostly usefully for grouping multiple screen update

calls into one to reduce flashing.

The WriteText method updates the insertion point which is what is

causing the scrolling (see documentation of WriteText

http://docs.wxwidgets.org/2.8/wx_wxtextctrl.html#wxtextctrlwritetext).

You may be able to work around this behavior by manipulating the

insertion point between the Freeze/Thaw and using AppendText (which

also moves the insertion point).

Other option is to use the StyledTextCtrl it is much more flexible in

these regards and has a more useful API for manipulating where/how

text is inserted in the buffer.

Cody