Back to index

gcompris  8.2.2
module_profiles.py
Go to the documentation of this file.
00001 #  gcompris - module_profiles.py
00002 #
00003 # Copyright (C) 2005 Bruno Coudoin and Yves Combe
00004 #
00005 #   This program is free software; you can redistribute it and/or modify
00006 #   it under the terms of the GNU General Public License as published by
00007 #   the Free Software Foundation; either version 2 of the License, or
00008 #   (at your option) any later version.
00009 #
00010 #   This program is distributed in the hope that it will be useful,
00011 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 #   GNU General Public License for more details.
00014 #
00015 #   You should have received a copy of the GNU General Public License
00016 #   along with this program; if not, write to the Free Software
00017 #   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 #
00019 
00020 import gnomecanvas
00021 import gcompris
00022 import gcompris.utils
00023 import gcompris.skin
00024 import gtk
00025 import gtk.gdk
00026 from gettext import gettext as _
00027 
00028 import module
00029 import profile_list
00030 
00031 # Database
00032 from pysqlite2 import dbapi2 as sqlite
00033 
00034 class Profiles(module.Module):
00035   """Administrating GCompris Profiles"""
00036 
00037 
00038   def __init__(self, canvas):
00039     print("Gcompris_administration __init__ profiles panel.")
00040     module.Module.__init__(self, canvas, "profiles", _("Profiles"))
00041 
00042   # Return the position it must have in the administration menu
00043   # The smaller number is the highest.
00044   def position(self):
00045     return 2
00046 
00047   def start(self, area):
00048     print "starting profiles panel"
00049 
00050     # Connect to our database
00051     self.con = sqlite.connect(gcompris.get_database())
00052     self.cur = self.con.cursor()
00053 
00054     # Create our rootitem. We put each canvas item in it so at the end we
00055     # only have to kill it. The canvas deletes all the items it contains automaticaly.
00056 
00057     self.rootitem = self.canvas.add(
00058         gnomecanvas.CanvasGroup,
00059         x=0.0,
00060         y=0.0
00061         )
00062 
00063     module.Module.start(self)
00064 
00065     frame = gtk.Frame(_("Profiles"))
00066     frame.show()
00067 
00068     self.rootitem.add(
00069       gnomecanvas.CanvasWidget,
00070       widget=frame,
00071       x=area[0]+self.module_panel_ofset,
00072       y=area[1]+self.module_panel_ofset,
00073       width=area[2]-area[0]-2*self.module_panel_ofset,
00074       height=area[3]-area[1]-2*self.module_panel_ofset,
00075       anchor=gtk.ANCHOR_NW,
00076       size_pixels=False)
00077 
00078     profile_list.Profile_list(frame, self.con, self.cur)
00079 
00080   def stop(self):
00081     print "stopping profiles panel"
00082     module.Module.stop(self)
00083 
00084     # Remove the root item removes all the others inside it
00085     self.rootitem.destroy()
00086 
00087     # Close the database
00088     self.cur.close()
00089     self.con.close()