Discussion:
[Tkinter-discuss] Questions about treeview
Bill Felton
2012-04-12 12:32:58 UTC
Permalink
Hi all,
Is it true that the ttk treeview widget 'swallows' right-mouse clicks?
We have a need that could be met with the treeview if we could only figure out how to get pop-up menus to work in that widget.
Our tests seem to show that regardless of where in the containment structure one binds <button-2> (widget, frmae, outframe, window, app), if the widget at the "bottom" of the stack is a treeview, the mouse button-2 event will not be caught.

Also, are there plans to fix the current problems with horizontal scrolling in treeviews? We have used the work-around of having an empty data column that the user can drag to the right; once the drag moves past the visible bounds of the frame containing the treeview the horizontal scrollbar appears. This seems clumsy and un-intuitive, so we're hoping there's another, better, way to get horizontal scrolling to work.

regards,
Bill
Michael Lange
2012-04-12 14:17:48 UTC
Permalink
Hi Bill,

Thus spoketh Bill Felton <subscriptions at cagttraining.com>
Post by Bill Felton
Hi all,
Is it true that the ttk treeview widget 'swallows' right-mouse clicks?
We have a need that could be met with the treeview if we could only
figure out how to get pop-up menus to work in that widget. Our tests
seem to show that regardless of where in the containment structure one
binds <button-2> (widget, frmae, outframe, window, app), if the widget
at the "bottom" of the stack is a treeview, the mouse button-2 event
will not be caught.
Maybe you simply confuse Button-2 (the button in the middle, under the
wheel) and Button-3 ? The following code works here just as expected:

from Tkinter import *
import ttk
root = Tk()
t = ttk.Treeview(root)
t.pack(fill='both', expand=1)

def test(event):
print 'hi'

t.bind('<3>', test)
root.mainloop()
Post by Bill Felton
Also, are there plans to fix the current problems with horizontal
scrolling in treeviews? We have used the work-around of having an
empty data column that the user can drag to the right; once the drag
moves past the visible bounds of the frame containing the treeview the
horizontal scrollbar appears. This seems clumsy and un-intuitive, so
we're hoping there's another, better, way to get horizontal scrolling
to work.
I haven't used the treeview much yet, so maybe I am missing something,
but I do not see any way to do it. Maybe the problem is the way
ttk reports the widget width to the window manager, just a guess though.
For some reason you cannot configure the width of a treeview, maybe this
is related. I am not sure if this is intentional or a bug, but I am afraid
there is not much we can do here, the problem is apparently on the Tcl/Tk
side. Maybe you could file a bug report there?

Regards

Michael


.-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-.

No one can guarantee the actions of another.
-- Spock, "Day of the Dove", stardate unknown
Bill Felton
2012-04-12 15:22:15 UTC
Permalink
Hi Michael,
Post by Michael Lange
Post by Bill Felton
Is it true that the ttk treeview widget 'swallows' right-mouse clicks?
We have a need that could be met with the treeview if we could only
figure out how to get pop-up menus to work in that widget. Our tests
seem to show that regardless of where in the containment structure one
binds <button-2> (widget, frmae, outframe, window, app), if the widget
at the "bottom" of the stack is a treeview, the mouse button-2 event
will not be caught.
Maybe you simply confuse Button-2 (the button in the middle, under the
from Tkinter import *
import ttk
root = Tk()
t = ttk.Treeview(root)
t.pack(fill='both', expand=1)
print 'hi'
t.bind('<3>', test)
root.mainloop()
I'm working on both Mac and PC with a test for which is current,
so using the correct button depending.
I know I've got that part right because I get pop-ups everywhere
else I expect/need them, just not in the tree.

I'm going to do some more testing as another review of the code,
and an attempt to mirror your simple test, shows that it's still
not working as I would expect, BUT the problem could lie in
some wrapper code that exists between the treeview and the
parent window.
I'll post a follow-up if I can't get things to work.
Post by Michael Lange
Post by Bill Felton
Also, are there plans to fix the current problems with horizontal
scrolling in treeviews? We have used the work-around of having an
empty data column that the user can drag to the right; once the drag
moves past the visible bounds of the frame containing the treeview the
horizontal scrollbar appears. This seems clumsy and un-intuitive, so
we're hoping there's another, better, way to get horizontal scrolling
to work.
I haven't used the treeview much yet, so maybe I am missing something,
but I do not see any way to do it. Maybe the problem is the way
ttk reports the widget width to the window manager, just a guess though.
For some reason you cannot configure the width of a treeview, maybe this
is related. I am not sure if this is intentional or a bug, but I am afraid
there is not much we can do here, the problem is apparently on the Tcl/Tk
side. Maybe you could file a bug report there?
Regards
Michael
Thanks, I appreciate the situation and will try to get a bug
report filed with them.

regards,
Bill

Loading...