In below picture you can see the 3 parent child window. actually I made one code which will show all child according to parent. that is showing correctly but i want username & password column editable for database parent only(like as 3rd window). other should not be editable.
In my case all child of parent is editable.
here is my code
#!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk, gobject
import os
import cairo, gio, pango, pangocairo, atk
class BasicTreeViewExample:
# close the window and quit
def delete_event(self, widget, event, data=None):
gtk.main_quit()
return False
def col1_toggled_cb( self, cell, path, model ):
model[path][1] = not model[path][1]
def on_cell_edited(self, cell, path_string, new_text, model):
print "hi"
#cell.set_property('editable', False)
iter = model.get_iter_from_string(new_text)
path = model.get_path(iter)[0]
column = cell.get_data("username")
def __init__(self):
# Create a new window
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_title("Basic TreeView Example")
self.window.set_size_request(400, 400)
self.window.connect("delete_event", self.delete_event)
self.treestore = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_BOOLEAN,gobject.TYPE_BOOLEAN, gobject.TYPE_STRING, gobject.TYPE_STRING)
for parent in range(2):
piter = self.treestore.append(None, ['Computer %i' % parent, False,False, '', ''])
pit = self.treestore.append(piter, ['Drive', False,False, '', ''])
pith = self.treestore.append(piter, ['Database', False,False, '', ''])
for child in range(2):
self.treestore.append(pit, ['child', True,True, '', ''])
for child in range(2):
self.treestore.append(pith, ['child', True,True, 'user', 'psw'])
self.treeview = gtk.TreeView(self.treestore)
self.cell = gtk.CellRendererText()
self.tvcolumn = gtk.TreeViewColumn("Computer Name", self.cell, text=0)
self.cell.set_property( 'editable', False )
self.cell0 = gtk.CellRendererToggle()
self.tvcolumn0 = gtk.TreeViewColumn("Select Drive", self.cell0 , active=1, visible=2)
self.cell0.set_property('activatable', True)
self.cell0.connect( 'toggled', self.col1_toggled_cb, self.treestore )
self.cell1 = gtk.CellRendererText()
self.tvcolumn1 = gtk.TreeViewColumn("username", self.cell1, text=3, visible=2)
self.cell1.set_property( 'editable', True )
self.cell1.connect("editing-started", self.on_cell_edited, self.treestore)
self.cell2 = gtk.CellRendererText()
self.tvcolumn2 = gtk.TreeViewColumn("password", self.cell2, text=4, visible=2)
self.cell2.set_property( 'editable', True )
self.treeview.append_column(self.tvcolumn)
self.treeview.append_column(self.tvcolumn0)
self.treeview.append_column(self.tvcolumn1)
self.treeview.append_column(self.tvcolumn2)
self.treeview.set_reorderable(True)
self.window.add(self.treeview)
self.window.show_all()
def main():
gtk.main()
if __name__ == "__main__":
tvexample = BasicTreeViewExample()
main()
Anybody help me for this problem.
Thanks...