Hi,
I fear, there isn't a simple way of doing this out of the box using TextCtrl.
You probably found my older post for this
http://wxpython-users.1045709.n5.nabble.com/problem-getting-the-HitTest-position-after-scrolling-td2370732.html
http://wxpython-users.1045709.n5.nabble.com/scrollwin-event-of-a-wx-TextCtrl-on-linux-Kubuntu-td2372230.html
where the recommendations imply, one would be happier using another widget.
Anyway, you can try to inspect the supported events and many other
properties ot the UI using wxPython Widget Inspection Tool (WIT)
http://wiki.wxpython.org/Widget%20Inspection%20Tool
you just add the following lines in your code
import wx.lib.inspection
wx.lib.inspection.InspectionTool().Show()
and locate the needed widget (i.e. TextCtrl), then you can see and see
the events generated with some actions in your app (in the "Events"
part of WIT).
Now I see multiple scrolling events (which may or may not help you -
possibly some of them could be newer additions (?)) - using Python
2.7.2 on win32, wxPython 2.9.1.1 (msw-unicode) - win 7.
some of the ones shown via dir(wx) are:
'EVT_SCROLL', 'EVT_SCROLLBAR', 'EVT_SCROLLWIN',
'EVT_SCROLLWIN_BOTTOM', 'EVT_SCROLLWIN_LINEDOWN',
'EVT_SCROLLWIN_LINEUP', 'EVT_SCROLLWIN_PAGEDOWN',
'EVT_SCROLLWIN_PAGEUP', 'EVT_SCROLLWIN_THUMBRELEASE',
'EVT_SCROLLWIN_THUMBTRACK', 'EVT_SCROLLWIN_TOP', 'EVT_SCROLL_BOTTOM',
'EVT_SCROLL_CHANGED', 'EVT_SCROLL_ENDSCROLL', 'EVT_SCROLL_LINEDOWN',
'EVT_SCROLL_LINEUP', 'EVT_SCROLL_PAGEDOWN', 'EVT_SCROLL_PAGEUP',
'EVT_SCROLL_THUMBRELEASE', 'EVT_SCROLL_THUMBTRACK', 'EVT_SCROLL_TOP',
The char events for line: up, down, page: up/down (and possibly
continuous left/right causing scrolling) as well as selecting the text
with the mouse involving scrolling would probably have to be handled
separately anyway.
cf. some key events like WXK_UP, WXK_DOWN, WXK_PAGEUP, WXK_PAGEDOWN,
but possibly many other can result in scrolling (writing or deleting
multiple lines of text...)
http://www.wxpython.org/docs/api/wx.KeyEvent-class.html
One can maybe use simple continuous position checks with a timer. It
might work well enough, with some delay.
I'd really like to learn some straightforward way for such tasks too.
regards,
vbr
···
2011/6/21 fzix <fzho@nieir.com.au>:
Hi all,
I'm trying to build a app that contains two multiline textctrl
(richtextctrl's ok too) next to each other, with one serving as user input
and the other output (think it as some sort of translation tool).
A requirement for this app is that when the user scrolls up/down in the
"input" textctrl, the other textctrl should follow and scroll to the same
position as input, thus I need to somehow "capture" the scrolling of the
input and that's where I run into problem: I'm unable to find out what
events are triggered when the scrolling happens.
EVT_SCROLL clearly won't work, and I've read somewhere here that
EVT_SCROLLWIN works only because a happy accident - in my case I can't even
use EVT_SCROLLWIN as a substitute, for that it only captures movement on
thumb and click on scroll bar but unable to handle scrolls triggered by
keyboard (pgup, pgdown, up, down etc).
There're just too many possible ways(mouse-wheel, keyboard, scroll via
scrollbar etc) to scroll the textctrl to utilize some dodgy key-down
workarounds I can think of, so em, any suggestions?
much appreciated,
F