version=pmwiki-2.0.13 ordered=1 urlencoded=1 agent=Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.10) Gecko/20050925 Firefox/1.0.4 (Debian package 1.0.4-2sarge5) author=FiFi host=80.200.230.88 name=Docu.SlidePyGTK rev=4 targets= text=!Introduction à PyGTK%0a%0a!Introduction à PyGTK%0a%0aCréer des applications graphiques avec Python et GTK%0a%0a!Python%0a%0aLanguage :%0a%0a*orienté objet %0a*relativement simple à apprendre%0a*avec de nombreux modules déjà existants%0a%0a!GTK%0a%0aGTK =~ "Gimp ToolKit"%0a%0aLe "look" Gnome, ensemble d'objets graphiques permettant à tout un chacun de créer son interface graphique dans une application GTK%0a%0a!Nous avons besoin de ...%0a%0aPremièrement il faut importer les modules nécessaires%0a%0a@@import pygtk\\%0aimport gtk@@%0a%0a!Créer une classe de base%0a%0a@@class HelloFSUGAr(object):@@%0a%0aNous créons une class qui représentera une simple fenêtre (qui contiendra notre greeting - voir suite)%0a%0a!__init__(self)%0a%0aIl nous faut initialiser le composant de base, la fenêtre (window)%0a%0a@@def __init__(self):\\%0aself.window = gtk.Window(gtk.WINDOW_TOPLEVEL)@@%0a%0aceci va nous créer un object window dans l'objet instancié à partir de la class MainClass%0a%0a!Ajouter un label%0a%0aNous allons ajouter une simple zone de texte non modifiable%0a%0a@@self.lbl = gtk.Label("Hello FSUGAr")\\%0aself.window.set_default_size(150,50)@@%0a%0a!Lier le label%0a%0aAjouter le label à notre window%0a%0a@@self.window.add(self.lbl)@@%0a%0aAfficher le window et la label%0a%0a@@self.lbl.show()\\%0aself.window.show()@@%0a%0a!Le '''main'''%0a%0aNotre méthode main\\%0ala partie de l'application qui sera "lancée"%0a@@def main(self):\\%0a gtk.main()@@%0a%0a!Lancer l'application%0a%0a@@if __name__ == "__main__":\\%0a hello = MainClass()\\%0a hello.main()@@%0a%0a!Notre applications%0a%0a*[[http://www.fsugar.be/docu/pygtk/hello.py]] : l'exemple%0a*[[http://www.fsugar.be/docu/pygtk/hello2.py]] : une version "plus compliquée"%0a%0a!Exécuter%0a%0aPour exécuter l'application, rien de plus facile%0a*avoir python-gtk%0a*avoir python (l'interpréteur)%0a*savoir taper dans la console :\\%0a@@python hello.py@@ time=1134863166 author:1134863166=FiFi diff:1134863166:1134860568:minor=61,67d60%0a%3c !Le '''main'''%0a%3c %0a%3c Notre méthode main\\%0a%3c la partie de l'application qui sera "lancée"%0a%3c @@def main(self):\\%0a%3c gtk.main()@@%0a%3c %0a72,85c65%0a%3c hello.main()@@%0a%3c %0a%3c !Notre applications%0a%3c %0a%3c *[[http://www.fsugar.be/docu/pygtk/hello.py]] : l'exemple%0a%3c *[[http://www.fsugar.be/docu/pygtk/hello2.py]] : une version "plus compliquée"%0a%3c %0a%3c !Exécuter%0a%3c %0a%3c Pour exécuter l'application, rien de plus facile%0a%3c *avoir python-gtk%0a%3c *avoir python (l'interpréteur)%0a%3c *savoir taper dans la console :\\%0a%3c @@python hello.py@@%0a\ No newline at end of file%0a---%0a> hello.main()@@%0a\ No newline at end of file%0a host:1134863166=80.200.230.88 author:1134860568=FiFi diff:1134860568:1134860500:minor=3,4d2%0a%3c !Introduction à PyGTK%0a%3c %0a host:1134860568=80.200.230.88 author:1134860500=FiFi diff:1134860500:1134860355:minor=8d7%0a%3c %0a22d20%0a%3c %0a55d52%0a%3c %0a host:1134860500=80.200.230.88 author:1134860355=FiFi diff:1134860355:1134860355:minor=1,60d0%0a%3c !Introduction à PyGTK%0a%3c %0a%3c Créer des applications graphiques avec Python et GTK%0a%3c %0a%3c !Python%0a%3c %0a%3c Language :%0a%3c *orienté objet %0a%3c *relativement simple à apprendre%0a%3c *avec de nombreux modules déjà existants%0a%3c %0a%3c !GTK%0a%3c %0a%3c GTK =~ "Gimp ToolKit"%0a%3c %0a%3c Le "look" Gnome, ensemble d'objets graphiques permettant à tout un chacun de créer son interface graphique dans une application GTK%0a%3c %0a%3c !Nous avons besoin de ...%0a%3c %0a%3c Premièrement il faut importer les modules nécessaires%0a%3c @@import pygtk\\%0a%3c import gtk@@%0a%3c %0a%3c !Créer une classe de base%0a%3c %0a%3c @@class HelloFSUGAr(object):@@%0a%3c %0a%3c Nous créons une class qui représentera une simple fenêtre (qui contiendra notre greeting - voir suite)%0a%3c %0a%3c !__init__(self)%0a%3c %0a%3c Il nous faut initialiser le composant de base, la fenêtre (window)%0a%3c %0a%3c @@def __init__(self):\\%0a%3c self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)@@%0a%3c %0a%3c ceci va nous créer un object window dans l'objet instancié à partir de la class MainClass%0a%3c %0a%3c !Ajouter un label%0a%3c %0a%3c Nous allons ajouter une simple zone de texte non modifiable%0a%3c %0a%3c @@self.lbl = gtk.Label("Hello FSUGAr")\\%0a%3c self.window.set_default_size(150,50)@@%0a%3c %0a%3c !Lier le label%0a%3c %0a%3c Ajouter le label à notre window%0a%3c %0a%3c @@self.window.add(self.lbl)@@%0a%3c %0a%3c Afficher le window et la label%0a%3c @@self.lbl.show()\\%0a%3c self.window.show()@@%0a%3c %0a%3c !Lancer l'application%0a%3c %0a%3c @@if __name__ == "__main__":\\%0a%3c hello = MainClass()\\%0a%3c hello.main()@@%0a\ No newline at end of file%0a host:1134860355=80.200.230.88