TreeEditor scroll location

8 views
Skip to first unread message

Daniel Farrell

unread,
Sep 14, 2021, 11:25:35 AM9/14/21
to Enthought Tool Suite users
Hello everyone,

I'm trying to control the scroll location of TreeEditor. I know this is not exposed by TraitsUI. So, how can I access the underlying toolkit to set the scroll location?

I've put together a lean example here that shows how I am using it in a large project, https://gist.github.com/danieljfarrell/75294c9601fb2f336dc97d39394c40f7

I'm using an EDM environment, Python 2.7.15, key versions of packages are shown below (note this is a WX application),
traits                   5.1.2-1       enthought/free
traitsui                6.1.3-2       enthought/free
wxpython           3.0.2.0-7    enthought/free

Cheers,

Dan

Corran Webster

unread,
Sep 14, 2021, 12:25:49 PM9/14/21
to Enthought Tool Suite users
Hi Dan,

the toolkit-level control is usually exposed via the control attribute of the editor, which you can in turn get at either via the UIInfo or the UI objects.  From your snippet, since you are using a ModelView, the easiest would be something like self.info.model.editor.control (going from memory, the "editor" may not be needed), but you can also do editors = self.info.ui.get_editors("model") and then something like editors[0].control which can correctly handle situations where you might have multiple items viewing the same trait.

That should give you the Wx-level control that you can then work with directly.

If you need to do some setup on the control at UI start time, probably the easiest way to do that is to override the ModelView's init() method (not __init__()!) to do whatever setup is needed.

Hopefully that should get you started.  If what you are considering is something that would be generically useful we would also likely accept PRs that improve the Wx tree editor.

Hope this helps,
-- Corran

Reply all
Reply to author
Forward
0 new messages