List Info

Thread: Re: Fwd: Tix hlist-clearing selection




Re: Fwd: Tix hlist-clearing selection
country flaguser name
Canada
2007-08-06 16:57:04
Your script works as expected and I think the problem in my script is a conflict when importing modules. The following are modules loaded order:
 
from Tkinter import *
from copy import copy, deepcopy
import Tix
import tkFileDialog
import Tkinter as Tk
Is there a way i can resolve the conflict between tkinter and tix without removing tkinter?
 
Thanks,
Hani
 
----- Original Message ----
From: James Brotchie <brotchiegmail.com&gt;
To: hani abraham <abraham_h101yahoo.ca&gt;
Cc: Tkinter-discusspython.org
Sent: Sunday, August 5, 2007 7:16:41 AM
Subject: Re: [Tkinter-discuss] Fwd: Tix hlist-clearing selection

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.4maint compiled 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):
 &nbsp;  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_h101yahoo.ca" target=_blank rel=nofollow>abraham_h101yahoo.ca&gt; 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 < brotchiegmail.com" target=_blank rel=nofollow> brotchiegmail.com>
To: Tkinter-discusspython.org" target=_blank rel=nofollow>Tkinter-discusspython.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):
&nbsp; &nbsp; def __init__(self, master=None, cnf={}, **kw):
 &nbsp; &nbsp; &nbsp;  TixWidget.__init__(self, master, 'tixTree',
 &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; ['options'], cnf, kw)
   ; &nbsp; &nbsp; self.subwidget_list ['hlist'] = _dummyHList(self, 'hlist')
&nbsp;   ; &nbsp;  self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
 &nbsp; &nbsp; &nbsp;  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_h101yahoo.ca" target=_blank rel=nofollow> abraham_h101yahoo.ca&gt; 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.

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discusspython.org" target=_blank rel=nofollow>Tkinter-discusspython.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




Be smarter than spam. See how smart SpamGuard is at giving junk email the boot with the All-new Yahoo! Mail
Trapping event for Toplevel()
country flaguser name
United States
2007-08-07 10:08:30
Hi,

I would like to know if there is a way to trap the kill
button event in a 
Toplevel window. I'm having problems with a dialog which has
a "Close" 
button, but users keep closing it with the kill button (the
big X at the 
upper right corner). After such a close, the application
refuses to 
re-open the dialog, throwing instead an exception:

File "C:PYTHON24liblib-tkTkinter.py", line
1541, in wm_withdraw
   return self.tk.call('wm', 'withdraw', self._w)
TclError: bad window path name ".14221680"

My guess is that I must trap the kill event as well but I
don't know how 
to do it.

Gerardo

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discusspython.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Re: Trapping event for Toplevel()
country flaguser name
United States
2007-08-07 12:54:16
On Tue, Aug 07, 2007 at 11:08:30AM -0400, Gerardo Juarez
wrote:
			.
			.
			.
> I would like to know if there is a way to trap the kill
button event in a 
> Toplevel window. I'm having problems with a dialog
which has a "Close" 
> button, but users keep closing it with the kill button
(the big X at the 
> upper right corner). After such a close, the
application refuses to 
> re-open the dialog, throwing instead an exception:
> 
> File "C:PYTHON24liblib-tkTkinter.py",
line 1541, in wm_withdraw
>    return self.tk.call('wm', 'withdraw', self._w)
> TclError: bad window path name ".14221680"
> 
> My guess is that I must trap the kill event as well but
I don't know how 
> to do it.
			.
			.
			.
Read about WM_DELETE_WINDOW in <URL:
http://effbot.org/tkinterbook/tkinter-events-and-bi
ndings.htm >
or <URL:
http://www.astro.washington.edu/owen/Tki
nterSummary.html#ProtocolHandler >.
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discusspython.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )