Re: How to set focus on a text view when tree selection changed?
- From: smartkenny <smartkenny gmail com>
- To: Milosz Derezynski <internalerror gmail com>
- Cc: "gtk-list gnome org" <gtk-list gnome org>
- Subject: Re: How to set focus on a text view when tree selection changed?
- Date: Sun, 07 Mar 2010 17:57:15 -0800
Hello, Milosz
Thank you for answer my question. But it doesn't work. Here's my program:
#!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk
def wrap(widget):
sw = gtk.ScrolledWindow()
sw.add(widget)
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
sw.set_border_width(1)
return sw
def on_selection_changed(selection):
selection.get_tree_view().grab_focus()
if __name__ == "__main__":
paned = gtk.HPaned()
treestore = gtk.TreeStore(str)
new_iter = treestore.append(None)
treestore.set(new_iter, 0, '00000')
new_iter = treestore.append(None)
treestore.set(new_iter, 0, '11111')
new_iter = treestore.append(None)
treestore.set(new_iter, 0, '22222')
new_iter = treestore.append(None)
treestore.set(new_iter, 0, '33333')
new_iter = treestore.append(None)
treestore.set(new_iter, 0, '44444')
treeview = gtk.TreeView(treestore)
treeview.set_enable_search(False)
treeview.get_selection().connect_after('changed', on_selection_changed)
column = gtk.TreeViewColumn();
renderer = gtk.CellRendererText()
column.pack_start(renderer, False)
column.add_attribute(renderer, 'text', 0)
treeview.append_column(column)
paned.add1(wrap(treeview))
textview = gtk.TextView()
paned.add2(wrap(textview))
paned.set_position(250)
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.set_default_size(800, 600)
window.add(paned)
window.show_all()
gtk.main()
Thank you!
Kenny
Milosz Derezynski wrote:
You need to get the TreeSelection from the TreeView and connect to
that's "changed" signal, and make sure you connect_after.
Sent from my iPod
On 07.03.2010, at 19:25, smartkenny <smartkenny gmail com> wrote:
Hi, all
Searched for a long time but didn't find any hints on this. Here's my
layout:
-------------------------
| | |
| tree view | text view |
| | |
-------------------------
When clicked on a tree view row, I am going to change text in text
view accordingly AND let text view grab focus, so that whenever I
press keys it put characters into the text view.
I tried to connect "changed" on tree view and grab focus on text
view, but it didn't work, the focus is still on tree view. So when I
press keys it doesn't put into the text view.
Can any body please give me a clue how to do this? Thank you very much.
Kenny
_______________________________________________
gtk-list mailing list
gtk-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]