[wxPython-users] prevent scrolling in multiline wx.TextCtrl.AppendText?

1,342 views
Skip to first unread message

Nathaniel Echols

unread,
May 5, 2010, 7:07:24 PM5/5/10
to wxpython-users
I use the TextCtrl to display log output from a long-running process, and call AppendText() as needed to add new lines as my GUI receives them.  A senior colleague complained that this causes the control to jump to the end, which makes it difficult to inspect a static section of text.  Is there a simple way to avoid this?  (I think he's using a Mac, if it matters.)

thanks,
Nat

--
To unsubscribe, send email to wxPython-user...@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Robin Dunn

unread,
May 6, 2010, 1:10:31 PM5/6/10
to wxpytho...@googlegroups.com
On 5/5/10 4:07 PM, Nathaniel Echols wrote:
> I use the TextCtrl to display log output from a long-running process,
> and call AppendText() as needed to add new lines as my GUI receives
> them. A senior colleague complained that this causes the control to
> jump to the end, which makes it difficult to inspect a static section of
> text. Is there a simple way to avoid this? (I think he's using a Mac,
> if it matters.)

Not with TextCtrl. It seems like somebody else was working on this
problem recently, not sure if it was here or in the IRC channel. I
think they ended up making a custom control for displaying log messages
so they could control scrolling.

--
Robin Dunn
Software Craftsman
http://wxPython.org

Mike Driscoll

unread,
May 6, 2010, 1:46:39 PM5/6/10
to wxPython-users


On May 6, 12:10 pm, Robin Dunn <ro...@alldunn.com> wrote:
> On 5/5/10 4:07 PM, Nathaniel Echols wrote:
>
> > I use the TextCtrl to display log output from a long-running process,
> > and call AppendText() as needed to add new lines as my GUI receives
> > them.  A senior colleague complained that this causes the control to
> > jump to the end, which makes it difficult to inspect a static section of
> > text.  Is there a simple way to avoid this?  (I think he's using a Mac,
> > if it matters.)
>
> Not with TextCtrl.  It seems like somebody else was working on this
> problem recently, not sure if it was here or in the IRC channel.  I
> think they ended up making a custom control for displaying log messages
> so they could control scrolling.
>
> --
> Robin Dunn
> Software Craftsmanhttp://wxPython.org
>

I remember someone talking about this too...last week or the week
before. It sounded like they were going to write a custom widget, so I
told them to contribute it back when it was done. I haven't heard
anything since.

If you figure it out Nathaniel, be sure to drop us a line.

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

Bryan Oakley

unread,
May 6, 2010, 2:38:09 PM5/6/10
to wxpytho...@googlegroups.com
On Wed, May 5, 2010 at 6:07 PM, Nathaniel Echols
<nathanie...@gmail.com> wrote:
> I use the TextCtrl to display log output from a long-running process, and
> call AppendText() as needed to add new lines as my GUI receives them.  A
> senior colleague complained that this causes the control to jump to the end,
> which makes it difficult to inspect a static section of text.  Is there a
> simple way to avoid this?  (I think he's using a Mac, if it matters.)
> thanks,
> Nat

If I do something like this, no automatic scrolling happens for me
(not tested on a Mac though...)

insert = text.GetInsertionPoint()
text.AppendText(whatever)
text.SetInsertionPoint(insert)

Does that work for you? What I find works best is to determine if the
view is currently at the bottom. If it is, do the automatic scrolling.
If not (meaning the user has scrolled up to look at something) , don't
do the automatic scrolling.

Jeff

unread,
May 18, 2010, 10:18:36 PM5/18/10
to wxPython-users
On May 7, 4:38 am, Bryan Oakley <bryan.oak...@gmail.com> wrote:
> On Wed, May 5, 2010 at 6:07 PM, Nathaniel Echols
>
> <nathaniel.ech...@gmail.com> wrote:
> > I use the TextCtrl to display log output from a long-running process, and
> > call AppendText() as needed to add new lines as my GUI receives them.  A
> > senior colleague complained that this causes the control to jump to the end,
> > which makes it difficult to inspect a static section of text.  Is there a
> > simple way to avoid this?  (I think he's using a Mac, if it matters.)
> > thanks,
> > Nat
>

Nat,

i accidentally discovered a potential way to do this on windows, ymmv
for mac. I was trying to solve the problem of too much logging into a
"debug" window slowing down my app, so i tried freezing (rightly or
wrongly, probably wrongly) the parent of the text control, i.e.

self._dbg.GetParent().Freeze()
self._dbg.AppendText(msg)
self._dbg.GetParent().Thaw()

this had the unintended side effect of scroll bar no longer moving to
the end after the append is done. You may be able to kludge that
together with detecting the user moving the scroll bar or find some
other way using this info.

regards,
-jeff

nani

unread,
Sep 26, 2016, 11:59:28 AM9/26/16
to wxPython-users, jv....@gmail.com
HI Jeff,

I am also using the TestCtrl,When ever object is updating.Every time vertical scroll bar is going down.I attached the demo script.Please share the answer.

Thanks,
Nani
tes - Copy.py
Reply all
Reply to author
Forward
0 new messages