ayuda un combo dentro de un treeview..

Milton Galo Patricio minostro en sicet.cl
Mie Jul 26 23:12:25 CEST 2006


siendo sincero no he leido tu código pero en inventarix[1] implemente un
comboboxentry...visita el cvs

[1]
http://chileforge.cl/scm/cvsweb.php/unstable/src/gui/windowGuiaDespacho.py?cvsroot=inventarix

te puse el url directo al fichero, salu2!!

2006/7/26, carlos villa <carlosfvo en gmail.com>:
>
> Buenas tardes, necesito poner un combo dentro de un treeview aqui esta
> el codigo el problema esque no me capta cuando selecciono un dato que
> hago el combo alguien sabe cual es el error ???         agredeceria la
> ayuda u correccion.
>
>
>
>
>
>
> import pygtk
> pygtk.require("2.0")
> import gtk, gobject
>
> tasks={"Do some programming": "Remember to update your software","Buy
> groceries": "Go to Asda after work","Watch some tv": "Remember to
> catch ER","Power up systems": "Turn on the client but leave the
> server"}
>
> class GUI_Controller:
>     """ The GUI class is the controller for our application """
>     def __init__(self):
>         # setup the main window
>         self.root = gtk.Window(type=gtk.WINDOW_TOPLEVEL)
>         self.root.set_title("CellRenderer Example")
>         self.root.connect("destroy", self.destroy_cb)
>         # Get the model and attach it to the view
>         self.mdl = Store.get_model()
>         self.view = Display.make_view( self.mdl )
>         # Add our view into the main window
>         self.root.add(self.view)
>         self.root.show_all()
>         return
>     def destroy_cb(self, *kw):
>         """ Destroy callback to shutdown the app """
>         gtk.main_quit()
>         return
>     def run(self):
>         """ run is called to set off the GTK mainloop """
>         gtk.main()
>         return
>
> class InfoModel:
>     """ The model class holds the information we want to display """
>     def __init__(self):
>         """ Sets up and populates our gtk.TreeStore """
>         self.list_store=gtk.ListStore(gobject.TYPE_STRING,
> gobject.TYPE_STRING)
>         # places the global people data into the list
>         # we form a simple tree.
>         """for item in tasks.items():
>             self.list_store.append(item)
>         return"""
>         self.list_store.append()
>     def get_model(self):
>         """ Returns the model """
>         if self.list_store:
>             return self.list_store
>         else:
>             return None
>
> class DisplayModel:
>     """ Displays the Info_Model model in a view """
>     def make_view( self, model ):
>         """ Form a view for the Tree Model """
>         self.view = gtk.TreeView( model )
>         # setup the text cell renderer and allows these
>         # cells to be edited.
>         self.renderer0 = gtk.CellRendererText()
>         self.renderer0.set_property( 'editable', True )
>         self.renderer0.connect( 'edited', self.col0_edited_cb, model )
>
>         self.renderer1 = gtk.CellRendererText()
>         self.renderer1.set_property( 'editable', True )
>         self.renderer1.connect( 'edited', self.col1_edited_cb, model )
>
>         # Connect column0 of the display with column 0 in our list model
>         # The renderer will then display whatever is in column 0 of
>         # our model .
>
>         self.modelo=gtk.ListStore(gobject.TYPE_STRING)
>
>         for i in range(10):
>                 self.modelo.append(str(i))
>
>         self.combo=gtk.CellRendererCombo()
>
>         self.combo.set_property('text-column', 0)
>         self.combo.set_property('model', self.modelo)
>         self.combo.set_property('editable', True)
>
>         self.combo.connect('edited', self.on_edited, self.modelo)
>
>         self.column0 = gtk.TreeViewColumn("Name", self.renderer0, text=0)
>         self.column1 = gtk.TreeViewColumn("Action", self.renderer1,
> text=1)
>         self.column2 = gtk.TreeViewColumn("Combo", self.combo, text=2)
>
>         self.column0.set_resizable(1)
>         self.column0.set_clickable(1)
>         self.column0.connect('clicked', self.ordenar)
>
>         self.column1.set_resizable(1)
>
>         # The columns active state is attached to the second column
>         # in the model.  So when the model says True then the button
>         # will show as active e.g on.
>         self.view.append_column( self.column0 )
>         self.view.append_column( self.column1 )
>         self.view.append_column(self.column2)
>         return self.view
>
>     def ordenar(self, widget):
>         self.column0.set_sort_column_id(0)
>         return
>
>     def on_edited(self,cell,path,new_text,model):
>             valor = model[path][0]
>             #v = value.parse(text)
>             #value.set(value=v)
>             model[path][1]=new_text
>
>
>     def col0_edited_cb( self, cell, path, new_text, model ):
>         """
>         Called when a text cell is edited.  It puts the new text
>         in the model so that it is displayed properly.
>         """
>         print "Cambio '%s' a '%s'" % (model[path][0], new_text)
>         #model[path][0] = new_text
>         return
>
>     def col1_edited_cb( self, cell, path, new_text, model ):
>         """
>         Called when a text cell is edited.  It puts the new text
>         in the model so that it is displayed properly.
>         """
>         print "Cambio '%s' a '%s'" % (model[path][1], new_text)
>         model[path][1] = new_text
>         self.list_store=Store.get_model()
>         self.list_store.append()
>         return
>
> if __name__ == '__main__':
>     Store = InfoModel()
>     Display = DisplayModel()
>     myGUI = GUI_Controller()
>     myGUI.run()
> _______________________________________________
> Python-es mailing list
> Python-es en aditel.org
> http://listas.aditel.org/listinfo/python-es
>



-- 
Milton Inostroza Aguilera




Más información sobre la lista de distribución Python-es