Back to index

gcompris  8.2.2
Public Member Functions | Public Attributes
oscar_and_friends.Gcompris_oscar_and_friends Class Reference

List of all members.

Public Member Functions

def __init__
def start
def end
def ok
def repeat
def config
def key_press
def pause
def set_level
def display_book_control
def display_scene_1_0
def display_texts_init
def display_next_text
def display_previous_text
def display_back_previous_buttons
def back_item_event
def next_item_event

Public Attributes

 gcomprisBoard
 next_item
 back_item
 text_item
 current_texts
 current_texts_index
 rootitem

Detailed Description

Testing gcompris python class

Definition at line 13 of file oscar_and_friends.py.


Constructor & Destructor Documentation

def oscar_and_friends.Gcompris_oscar_and_friends.__init__ (   self,
  gcomprisBoard 
)

Definition at line 17 of file oscar_and_friends.py.

00017 
00018   def __init__(self, gcomprisBoard):
00019     self.gcomprisBoard = gcomprisBoard
00020     self.next_item = None
00021     self.back_item = None
00022     self.text_item = None
00023 
00024     self.current_texts = None
00025     self.current_texts_index = 0
00026 
00027     #initialisation to default values. Some of them will be replaced by
00028     #the configured values.


Member Function Documentation

def oscar_and_friends.Gcompris_oscar_and_friends.back_item_event (   self,
  widget,
  event = None 
)

Definition at line 155 of file oscar_and_friends.py.

00155 
00156   def back_item_event(self, widget, event=None):
00157     if event.type == gtk.gdk.BUTTON_PRESS:
00158       if event.button == 1:
00159         self.display_previous_text()
00160         return True
00161     return False

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 57 of file oscar_and_friends.py.

00057 
00058   def config(self):
00059     print("Gcompris_oscar_and_friends config.")
00060 

Definition at line 144 of file oscar_and_friends.py.

00144 
00145   def display_back_previous_buttons(self):
00146     if(self.current_texts_index>0):
00147       self.back_item.show()
00148     else:
00149       self.back_item.hide()
00150 
00151     if(self.current_texts_index<len(self.current_texts)-1):
00152       self.next_item.show()
00153     else:
00154       self.next_item.hide()

Here is the caller graph for this function:

Definition at line 78 of file oscar_and_friends.py.

00078 
00079   def display_book_control(self):
00080     self.back_item = self.rootitem.add(
00081       gnomecanvas.CanvasPixbuf,
00082       pixbuf = gcompris.utils.load_pixmap(gcompris.skin.image_to_skin("button_backward.png")),
00083       x = gcompris.BOARD_WIDTH - 100,
00084       y = gcompris.BOARD_HEIGHT - 40
00085       )
00086     self.back_item.hide()
00087     self.back_item.connect("event", gcompris.utils.item_event_focus)
00088     self.back_item.connect("event", self.back_item_event)
00089 
00090     self.next_item = self.rootitem.add(
00091       gnomecanvas.CanvasPixbuf,
00092       pixbuf = gcompris.utils.load_pixmap(gcompris.skin.image_to_skin("button_forward.png")),
00093       x = gcompris.BOARD_WIDTH - 50,
00094       y = gcompris.BOARD_HEIGHT - 40
00095       )
00096     self.next_item.hide()
00097     self.next_item.connect("event", gcompris.utils.item_event_focus)
00098     self.next_item.connect("event", self.next_item_event)
00099 
00100     self.text_item = self.rootitem.add(
00101       gnomecanvas.CanvasText,
00102       x=gcompris.BOARD_WIDTH * 0.45,
00103       y=gcompris.BOARD_HEIGHT - 40.0,
00104       text="",
00105       font=gcompris.skin.get_font("gcompris/content"),
00106       fill_color="white",
00107       justification=gtk.JUSTIFY_CENTER
00108       )
00109     self.text_item.hide()

Here is the call graph for this function:

Definition at line 132 of file oscar_and_friends.py.

00132 
00133   def display_next_text(self):
00134     self.current_texts_index += 1
00135     if(self.current_texts_index < len(self.current_texts)):
00136       self.text_item.set(text=self.current_texts[self.current_texts_index])
00137       self.display_back_previous_buttons()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 138 of file oscar_and_friends.py.

00138 
00139   def display_previous_text(self):
00140     self.current_texts_index -= 1
00141     if(self.current_texts_index >= 0):
00142       self.text_item.set(text=self.current_texts[self.current_texts_index])
00143       self.display_back_previous_buttons()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 110 of file oscar_and_friends.py.

00110 
00111   def display_scene_1_0(self):
00112       gcompris.set_background(self.gcomprisBoard.canvas.root(),
00113                               "oscar_and_friends/scene1_0.png")
00114 
00115       self.display_texts_init(
00116         [
00117         _("Below the surface, Oscar the octopus and his friends sat on a rock,\nwatching the bad weather above them."),
00118         _("They were all happy that the storms never reached all the way down to them."),
00119         _("No matter how bad it was up there, the bottom was always calm and quiet."),
00120         _("Oscar's best friends were Charlie the crab and Sandy the sea-star.")
00121         ]
00122         )
00123 

Here is the call graph for this function:

Definition at line 124 of file oscar_and_friends.py.

00124 
00125   def display_texts_init(self, texts):
00126     self.current_texts = texts
00127     self.current_texts_index = 0
00128     self.text_item.set(text=self.current_texts[self.current_texts_index])
00129     self.display_back_previous_buttons()
00130     self.text_item.show()
00131 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 45 of file oscar_and_friends.py.

00045 
00046   def end(self):
00047     # Remove the root item removes all the others inside it
00048     self.rootitem.destroy()

def oscar_and_friends.Gcompris_oscar_and_friends.key_press (   self,
  keyval,
  commit_str,
  preedit_str 
)

Definition at line 61 of file oscar_and_friends.py.

00061 
00062   def key_press(self, keyval, commit_str, preedit_str):
00063     print("Gcompris_oscar_and_friends key press. %i %s" % (keyval, str))
00064 
00065     # Return  True  if you did process a key
00066     # Return  False if you did not processed a key
00067     #         (gtk need to send it to next widget)
00068     return True

def oscar_and_friends.Gcompris_oscar_and_friends.next_item_event (   self,
  widget,
  event = None 
)

Definition at line 162 of file oscar_and_friends.py.

00162 
00163   def next_item_event(self, widget, event=None):
00164     if event.type == gtk.gdk.BUTTON_PRESS:
00165       if event.button == 1:
00166         self.display_next_text()
00167         return True
00168     return False
00169 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 49 of file oscar_and_friends.py.

00049 
00050   def ok(self):
00051     print("Gcompris_oscar_and_friends ok.")
00052 

Definition at line 69 of file oscar_and_friends.py.

00069 
00070   def pause(self, pause):
00071     print("Gcompris_oscar_and_friends pause. %i" % pause)
00072 

Definition at line 53 of file oscar_and_friends.py.

00053 
00054   def repeat(self):
00055     print("Gcompris_oscar_and_friends repeat.")
00056 

Here is the caller graph for this function:

Definition at line 73 of file oscar_and_friends.py.

00073 
00074   def set_level(self, level):
00075     print("Gcompris_oscar_and_friends set level. %i" % level)

Definition at line 29 of file oscar_and_friends.py.

00029 
00030   def start(self):
00031     print("Gcompris_oscar_and_friends start.")
00032 
00033     gcompris.bar_set(0)
00034     # Create our rootitem. We put each canvas item in it so at the end we
00035     # only have to kill it. The canvas deletes all the items it contains automaticaly.
00036     self.rootitem = self.gcomprisBoard.canvas.root().add(
00037       gnomecanvas.CanvasGroup,
00038       x=0.0,
00039       y=0.0
00040       )
00041 
00042     self.display_book_control()
00043     self.display_scene_1_0()
00044 


Member Data Documentation

Definition at line 20 of file oscar_and_friends.py.

Definition at line 23 of file oscar_and_friends.py.

Definition at line 24 of file oscar_and_friends.py.

Definition at line 18 of file oscar_and_friends.py.

Definition at line 19 of file oscar_and_friends.py.

Definition at line 35 of file oscar_and_friends.py.

Definition at line 21 of file oscar_and_friends.py.


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