Back to index

gcompris  8.2.2
module_boards.py
Go to the documentation of this file.
00001 #  gcompris - module_boards.py
00002 #
00003 # Copyright (C) 2005 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 gcompris.admin
00025 import gtk
00026 import gtk.gdk
00027 from gettext import gettext as _
00028 import sys;
00029 
00030 # Database
00031 from pysqlite2 import dbapi2 as sqlite
00032 
00033 import module
00034 import board_list
00035 
00036 class Boards(module.Module):
00037   """Administrating GCompris Boards"""
00038 
00039 
00040   def __init__(self, canvas):
00041     print("Gcompris_administration __init__ boards panel.")
00042     module.Module.__init__(self, canvas, "boards", _("Boards"))
00043 
00044   def start(self, area):
00045     print "starting boards panel"
00046 
00047     # Create our rootitem. We put each canvas item in it so at the end we
00048     # only have to kill it. The canvas deletes all the items it contains automaticaly.
00049 
00050     self.rootitem = self.canvas.add(
00051         gnomecanvas.CanvasGroup,
00052         x=0.0,
00053         y=0.0
00054         )
00055 
00056     module.Module.start(self)
00057 
00058     # Connect to our database
00059     self.con = sqlite.connect(gcompris.get_database())
00060     self.cur = self.con.cursor()
00061 
00062     frame = gtk.Frame(_("Boards"))
00063     frame.show()
00064 
00065     self.rootitem.add(
00066       gnomecanvas.CanvasWidget,
00067       widget=frame,
00068       x=area[0]+self.module_panel_ofset,
00069       y=area[1]+self.module_panel_ofset,
00070       width=area[2]-area[0]-2*self.module_panel_ofset,
00071       height=area[3]-area[1]-2*self.module_panel_ofset,
00072       anchor=gtk.ANCHOR_NW,
00073       size_pixels=False)
00074 
00075     board_list.Board_list(self.con, self.cur,
00076                           frame)
00077 
00078   def stop(self):
00079     print "stopping boards panel"
00080     module.Module.stop(self)
00081 
00082     # Remove the root item removes all the others inside it
00083     self.rootitem.destroy()
00084 
00085     # Close the database
00086     self.cur.close()
00087     self.con.close()