logo       

Re: Forbid focusing of TreeView columns: msg#00125

gnome.gtk+.python

Subject: Re: Forbid focusing of TreeView columns

Franck Pommereau wrote:
I believe this is impossible (or should be). Anything that can be
clicked should also be reachable via the keyboard, which means it must
be able to receive focus.


A button can behave this way, just use:

button.set_property("can-focus", gtk.FALSE)

and the button will not get the keyboard while staying clickable.


That said, I'm just guessing that this is a general gtk usability
principle -- I could be wrong


I hope you're wrong, otherwise I'll find no solution to my problem. :-/

The column header is just a button. The trick is getting a pointer to it. This can be done using this hack, where 'col' if the gtk.TreeViewColumn object:

label = gtk.Label('_Foo')
label.set_use_underline(True)
col.set_widget(label)
label.show()
w = label
while not isinstance(w, gtk.Button):
w = w.get_parent()
w.set_property("can-focus", False)

Note how I also add a mnemonic to the new label widget so that the column header is still accessible from the keyboard.

--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
_______________________________________________
pygtk mailing list pygtk@xxxxxxxxxx
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise