[Tkinter-discuss] Fwd: Tix hlist-clearing selection

James Brotchie brotchie at gmail.com
Sun Aug 5 13:16:41 CEST 2007


Does this script function as expected on your installation? You should be
able to select multiple items in the tree and then clear the selection with
the button.

Works for me on both winxp and ubuntu with 2.6trunk, 2.5maint and
2.4maintcompiled against
tcl8.4.12, tix-8.4.0, tk8.4.12. Which version of python and what tcl/tk/tix
libraries are you using?

cat hlisttest.py

from Tix import *

def clearSelection(hlist):
    hlist.selection_clear()

tk = Tk()

# create and configure tree
tree = Tree(tk)
tree.hlist['selectmode'] = EXTENDED
tree.hlist['wideselection'] = TRUE
tree.hlist['background'] = 'white'

# add a couple of tree nodes
tree.hlist.add("test1", text="Hello world")
for i in range(5):
    tree.hlist.add_child("test1", text="item%d" % i)

# add button for selection clear
Button(tk, text="Clear Selection", command=lambda:clearSelection(tree.hlist
)).pack()

# pack tree
tree.pack(expand=TRUE, fill=BOTH)

tk.mainloop()

On 8/5/07, hani abraham <abraham_h101 at yahoo.ca> wrote:
>
> Yes, i used the hlist component of the tree but nothing happens. The thing
> is I can clear the selection if I use selection_set then selection_clear but
> i can't clear the selection when it's highlight with a mouse.
>
> Thanks,
> Hani
> ----- Original Message ----
> From: James Brotchie <brotchie at gmail.com>
> To: Tkinter-discuss at python.org
> Sent: Sunday, August 5, 2007 12:50:55 AM
> Subject: [Tkinter-discuss] Fwd: Tix hlist-clearing selection
>
> Hey Hani,
>
> Are you sure you are calling the selection_clear method of the hlist child
> widget and not the parent tree?
>
> eg.
> tree = Tix.Tree(root)
> tree.hlist.selection_clear ()
>
> If you look in Tix.py you can see that Tree is a compound widget
> containing two scrollbars and a hlist.
>
> class Tree(TixWidget):
>     def __init__(self, master=None, cnf={}, **kw):
>         TixWidget.__init__(self, master, 'tixTree',
>                            ['options'], cnf, kw)
>         self.subwidget_list ['hlist'] = _dummyHList(self, 'hlist')
>         self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
>         self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
>
> Thus to clear the hlist selection you must address the child hlist
> directly and not its parent Tree widget.
>
> Cheers,
> James
>
>  On 8/5/07, hani abraham <abraham_h101 at yahoo.ca> wrote:
>
> >   Hi,
> >
> > I'm new to python and i'm using Tix Tree widget in my application. I'm
> > trying to clear the tree selection but no luck so far. I tried
> > selection_clear and anchor_clear but these aren't working. Can someone help?
> >
> >
> >
> > Thanks,
> > Hani
> >
> > ------------------------------
> > Ask a question on any topic and get answers from real people. *Go to
> > Yahoo! Answers.* <http://ca.answers.yahoo.com/>
> >
> > _______________________________________________
> > Tkinter-discuss mailing list
> > Tkinter-discuss at python.org
> > http://mail.python.org/mailman/listinfo/tkinter-discuss
> >
> >
>
>
> ------------------------------
> Be smarter than spam. See how smart SpamGuard is at giving junk email the
> boot with the *All-new Yahoo! Mail *<http://us.rd.yahoo.com/evt=40705/*http://mrd.mail.yahoo.com/try_beta?.intl=ca>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20070805/38483614/attachment.htm 


More information about the Tkinter-discuss mailing list