Back to index

gcompris  8.2.2
Public Member Functions | Public Attributes
administration.Gcompris_administration Class Reference

List of all members.

Public Member Functions

def __init__
def pause
def start
def end
def ok
def repeat
def config
def key_press
def select_event

Public Attributes

 gcomprisBoard
 current_panel
 current_panel_stopped
 rootitem
 select_area
 panel_area

Detailed Description

Administering GCompris

Definition at line 30 of file administration.py.


Constructor & Destructor Documentation

def administration.Gcompris_administration.__init__ (   self,
  gcomprisBoard 
)

Definition at line 34 of file administration.py.

00034 
00035   def __init__(self, gcomprisBoard):
00036     self.gcomprisBoard = gcomprisBoard
00037 
00038     # The panel being displayed
00039     self.current_panel = None
00040     self.current_panel_stopped = False
00041 
00042     # Create our rootitem. We put each canvas item in it so at the end we
00043     # only have to kill it. The canvas deletes all the items it contains automaticaly.
00044     self.rootitem = self.gcomprisBoard.canvas.root().add(
00045       gnomecanvas.CanvasGroup,
00046       x=0.0,
00047       y=0.0
00048       )
00049 
00050     gap = 10
00051     panel_x = 120
00052     self.select_area = (gap , gap, panel_x + gap , gcompris.BOARD_HEIGHT-gap)
00053     self.panel_area  = (panel_x + 2*gap ,
00054                         gap,
00055                         gcompris.BOARD_WIDTH-gap,
00056                         gcompris.BOARD_HEIGHT-gap)
00057 
00058 


Member Function Documentation

Definition at line 158 of file administration.py.

00158 
00159   def config(self):
00160     pass
00161 

Definition at line 144 of file administration.py.

00144 
00145   def end(self):
00146     # Stop current panel
00147     if(self.current_panel != None and not self.current_panel_stopped):
00148       self.current_panel.stop()
00149       self.current_panel_stopped = False

def administration.Gcompris_administration.key_press (   self,
  keyval,
  commit_str,
  preedit_str 
)

Definition at line 162 of file administration.py.

00162 
00163   def key_press(self, keyval, commit_str, preedit_str):
00164     #print("Gcompris_administration key press. %i" % keyval)
00165     return False

Definition at line 150 of file administration.py.

00150 
00151   def ok(self):
00152     pass
00153 

def administration.Gcompris_administration.pause (   self,
  pause 
)

Definition at line 59 of file administration.py.

00059 
00060   def pause(self, pause):
00061     if(self.current_panel != None):
00062       if pause:
00063         # Stop current panel
00064         self.current_panel.stop()
00065         self.current_panel_stopped = True
00066       else:
00067         # Restart the current panel
00068         self.current_panel.start(self.panel_area)
00069         self.current_panel_stopped = False
00070 

Definition at line 154 of file administration.py.

00154 
00155   def repeat(self):
00156     pass
00157 

Here is the caller graph for this function:

def administration.Gcompris_administration.select_event (   self,
  item,
  event,
  module 
)

Definition at line 169 of file administration.py.

00169 
00170   def select_event(self, item, event, module):
00171     if event.type == gtk.gdk.BUTTON_PRESS:
00172       if event.button == 1:
00173 
00174         # Do not reload it
00175         if(self.current_panel ==  module):
00176           return
00177 
00178         # Stop previous panel if any
00179         if(self.current_panel != None):
00180           self.current_panel.stop()
00181           self.current_panel_stopped = False
00182 
00183         self.current_panel = module
00184 
00185         # Start the new panel
00186         module.start(self.panel_area)
00187 

Definition at line 71 of file administration.py.

00071 
00072   def start(self):
00073 
00074     # Find the list of modules in admin/
00075     # that means all files, but __init__.py and module.py
00076     list_modules = []
00077 
00078     import glob
00079     m_list = glob.glob('admin/module_*.py')
00080     if m_list == []:
00081       m_list = glob.glob(gcompris.PYTHON_PLUGIN_DIR+'/admin/module_*.py')
00082     for file in m_list:
00083       m_name = file.split('/')[-1].split('.')[0].split('_')[1]
00084       list_modules.append(m_name)
00085 
00086     # Now import modules,
00087     # and get the list of string 'name.Name' for initialisation below.
00088     modules_init = []
00089 
00090     for module in list_modules:
00091       exec('from admin import module_' + module + ' as ' + module)
00092       modules_init.append(module+ '.' + module[0].upper() + module[1:])
00093 
00094     del list_modules
00095 
00096     self.gcomprisBoard.level=1
00097     self.gcomprisBoard.maxlevel=1
00098     self.gcomprisBoard.sublevel=1
00099     self.gcomprisBoard.number_of_sublevel=1
00100     gcompris.bar_set(0)
00101     gcompris.set_background(self.gcomprisBoard.canvas.root(),
00102                             gcompris.skin.image_to_skin("gcompris-bg.jpg"))
00103     gcompris.bar_set_level(self.gcomprisBoard)
00104 
00105     self.rootitem.add(
00106       gnomecanvas.CanvasRect,
00107       x1=self.select_area[0],
00108       y1=self.select_area[1],
00109       x2=self.select_area[2],
00110       y2=self.select_area[3],
00111       fill_color="white",
00112       outline_color_rgba=0x111199FFL,
00113       width_units=1.0
00114       )
00115 
00116     # A White background in the panel area
00117     self.rootitem.add(
00118       gnomecanvas.CanvasRect,
00119       x1=self.panel_area[0],
00120       y1=self.panel_area[1],
00121       x2=self.panel_area[2],
00122       y2=self.panel_area[3],
00123       fill_color="white",
00124       outline_color_rgba=0x111199FFL,
00125       width_units=1.0
00126       )
00127 
00128     # Get the menu position for each module
00129     # The list of modules
00130     modules_ordered = []
00131     for module in modules_init:
00132       p = eval(module +'(self.rootitem).position()')
00133       modules_ordered.append((p, module))
00134 
00135     # Display the menu in the selection area
00136     # The list of modules
00137     i = 0
00138     modules_ordered.sort()
00139     for tmodule in modules_ordered:
00140       module = tmodule[1]
00141       eval(module +'(self.rootitem).init(i, self.select_area, self.select_event)')
00142       i+=1
00143 

Here is the call graph for this function:


Member Data Documentation

Definition at line 38 of file administration.py.

Definition at line 39 of file administration.py.

Definition at line 35 of file administration.py.

Definition at line 52 of file administration.py.

Definition at line 43 of file administration.py.

Definition at line 51 of file administration.py.


The documentation for this class was generated from the following file: