Back to index

gcompris  8.2.2
module_groups.py
Go to the documentation of this file.
00001 #  gcompris - module_groups.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 # Database
00029 from pysqlite2 import dbapi2 as sqlite
00030 
00031 import module
00032 import group_list
00033 
00034 class Groups(module.Module):
00035   """Administrating GCompris Groups"""
00036 
00037 
00038   def __init__(self, canvas):
00039     print("Gcompris_administration __init__ groups panel.")
00040     module.Module.__init__(self, canvas, "groups", _("Groups"))
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 1
00046 
00047   def start(self, area):
00048     print "starting groups 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     # Call our parent start
00064     module.Module.start(self)
00065 
00066     frame = gtk.Frame(_("Groups"))
00067     frame.show()
00068 
00069     self.rootitem.add(
00070       gnomecanvas.CanvasWidget,
00071       widget=frame,
00072       x=area[0]+self.module_panel_ofset,
00073       y=area[1]+self.module_panel_ofset,
00074       width=area[2]-area[0]-2*self.module_panel_ofset,
00075       height=area[3]-area[1]-2*self.module_panel_ofset,
00076       anchor=gtk.ANCHOR_NW,
00077       size_pixels=False)
00078 
00079 
00080     group_list.Group_list(frame, self.con, self.cur)
00081 
00082 
00083   def stop(self):
00084     print "stopping groups panel"
00085     module.Module.stop(self)
00086 
00087     # Remove the root item removes all the others inside it
00088     self.rootitem.destroy()
00089 
00090     # Close the database
00091     self.cur.close()
00092     self.con.close()
00093 
00094