#!/usr/bin/python # Drill - Teo Serie # Copyright Hilaire Fernandes 2001 # Release under the terms of the GPL licence # You can get a copy of the license at http://www.gnu.org from gtk import * from gnome.ui import * from GDK import * from libglade import * exerciceTree = currentExercice = label = None def on_about_activate(obj): "display the about dialog" about = GladeXML ("drill.glade", "about").get_widget ("about") about.show () def on_new_activate (obj): global exerciceTree, currentExercice def selectTreeItem (item): global label label.set_text ("L'exercice " + item.get_data ("id") + "est s�lectionn�.") def deselectTreeItem (item): global label label.set_text ("L'exercice " + item.get_data ("id") + "est d�s�lectionn�.") def selectSubtree (subtree): global label label.set_text ("Aucun exercice de s�lectionn�") def addSubtree (name): global exerciceTree subTree = GtkTree () item = GtkTreeItem (name) exerciceTree.append (item) item.set_subtree (subTree) item.show () item.connect ("select", selectSubtree) return subTree def addExercice (category, title, id): item = GtkTreeItem (title) item.set_data ("id", id) category.append (item) item.show () item.connect ("select", selectTreeItem) item.connect ("deselect", deselectTreeItem) def addMathExercices (): subtree = addSubtree ("Math�matiques") addExercice (subtree, "Exercice 1", "Math. Ex1") addExercice (subtree, "Exercice 2", "Math. Ex2") def addFrenchExercices (): subtree = addSubtree ("Fran�ais") addExercice (subtree, "Exercice 1", "Fran�ais Ex1") addExercice (subtree, "Exercice 2", "Fran�ais Ex2") def addHistoryExercices (): subtree = addSubtree ("Histoire") addExercice (subtree, "Exercice 1", "Histoire Ex1") addExercice (subtree, "Exercice 2", "Histoire Ex2") def addGeographyExercices (): subtree = addSubtree ("G�ographie") addExercice (subtree, "Exercice 1", "G�ographie Ex1") addExercice (subtree, "Exercice 2", "G�ographie Ex2") def initDrill (): global exerciceTree, label wTree = GladeXML ("drill.glade", "drillApp") dic = {"on_about_activate": on_about_activate, "on_exit_activate": mainquit, "on_new_activate": on_new_activate} wTree.signal_autoconnect (dic) exerciceTree = wTree.get_widget ("exerciceTree") # Temporary until we implement real exercice paned = wTree.get_widget ("hpanedTree") label = GtkLabel ("Aucun exercice de s�lectionn�") label.show () paned.pack2 (label) # Free the GladeXML tree wTree.destroy () # Add the exercices addMathExercices () addFrenchExercices () addHistoryExercices () addGeographyExercices () initDrill () mainloop ()