[Glade-users] gtktreeview and libglade



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

to jan at stepien.com.pl


I send you a short program: it's in python, but has exactly the same
behavior than every langage: you'll find a very short example and 'll
see how to do it:

here is it:

******************
# -*- coding: UTF8 -*

#/usr/bin/env python

import sys

try:
  import gtk
  import gtk.glade
except:
  print "Vous devez installer pyGTK ou GTK version 2 ",
  print "ou mettre ? jour votre chemn PYTHONPATH "
  print "essayez: export PYTHONPATH=",
  print "/usr/(local)/lib/pythonxxx/site-packages/"
  sys.exit(1)


une_liste = [['Streit','Eric'],['Streit','Simon']]

class liste:

    def __init__(self,f_liste):
        self.ma_liste = f_liste
        self.ma_liste.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
        # le modele
        self.mon_modele = gtk.ListStore(str, str)
        self.ma_liste.set_headers_visible(True)
        #liaison entre modele et le widget
        self.ma_liste.set_model(self.mon_modele)
        # les cellules
        cellule_texte = gtk.CellRendererText()
        # les colonnes
        column = gtk.TreeViewColumn("Nom", cellule_texte, text=0)
        column.set_resizable(True)
        self.ma_liste.append_column(column)
        column = gtk.TreeViewColumn("Prenom", cellule_texte, text=1)
        column.set_resizable(True)
        self.ma_liste.append_column(column)     
        for n in range(0, len(une_liste)):
            self.mon_modele.append(une_liste[n])

        

class application:


    def __init__(self, glade_file):
        self.fenetre = gtk.glade.XML(glade_file)
        dic={   "on_window1_delete"     : self.on_window1_delete,
                "on_window1_destroy"    : self.on_window1_destroy}
        self.fenetre.signal_autoconnect(dic)
        #
        liste(self.fenetre.get_widget("treeview1"))

        

    def on_window1_delete(self,widget,event,data=None):
        print("Ev?nement delete !")
        return gtk.FALSE

    def  on_window1_destroy(self,widget,data=None):
        print("Ev?nement destroy !")
        gtk.main_quit()

    def main(self):
        gtk.main()


if __name__ == "__main__":
    mon_application = application("p17.glade")
    mon_application.main();


******************


hope this help,


Eric!
- -----
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGD1s5kouUNm4lemwRAghYAKCZC08arccWknq7zsgHjxhAKzEm3QCg54La
lvjh9bcI4WinTibAJoCkH04=
=Nh4P
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p17.glade
Type: application/x-glade
Size: 8172 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/glade-users/attachments/20070401/b94165bd/attachment-0001.bin 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]