Back to index

gcompris  8.2.2
Public Member Functions | Public Attributes
bargame.Gcompris_bargame.answer_button Class Reference

List of all members.

Public Member Functions

def __init__
def new_value
def has_focus
def set_number_of_balls
def answer_event

Public Attributes

 focus
 number_balls
 itemgroup
 background
 background_focused
 icone
 value
 text

Detailed Description

Definition at line 417 of file bargame.py.


Constructor & Destructor Documentation

def bargame.Gcompris_bargame.answer_button.__init__ (   self,
  root,
  scale,
  image,
  number_balls 
)

Definition at line 418 of file bargame.py.

00418 
00419     def __init__(self, root, scale, image, number_balls):
00420       self.focus = False
00421 
00422       self.number_balls = number_balls
00423 
00424       self.itemgroup = root.add(
00425         gnomecanvas.CanvasGroup,
00426         x = gcompris.BOARD_WIDTH - 200,
00427         )
00428 
00429       self.background = self.itemgroup.add(
00430         gnomecanvas.CanvasPixbuf,
00431         pixbuf = gcompris.utils.load_pixmap("images/enumerate_answer.png"),
00432         x=0,
00433         y=0
00434         )
00435       answer_bounds = self.background.get_bounds()
00436 
00437       self.itemgroup.set( y = gcompris.BOARD_HEIGHT - answer_bounds[3]-answer_bounds[1] - 5)
00438 
00439       self.background_focused = self.itemgroup.add(
00440         gnomecanvas.CanvasPixbuf,
00441         pixbuf = gcompris.utils.load_pixmap("images/enumerate_answer_focus.png"),
00442         x=0,
00443         y=0
00444         )
00445       self.background_focused.hide()
00446 
00447       self.icone = self.itemgroup.add(
00448         gnomecanvas.CanvasPixbuf,
00449         pixbuf = image,
00450         x=10,
00451         y=20
00452         )
00453       bounds = self.icone.get_bounds()
00454       self.icone.set(width  = (bounds[2]-bounds[0])*scale,
00455                      height = (bounds[3]-bounds[1])*scale,
00456                      width_set  = True,
00457                      height_set = True)
00458 
00459       self.value = number_balls[0]
00460 
00461       self.text = self.itemgroup.add(
00462         gnomecanvas.CanvasText,
00463         x = answer_bounds[2]-answer_bounds[0] - 50,
00464         y = 40,
00465         fill_color_rgba=0xff0000ffL,
00466         font=gcompris.skin.get_font("gcompris/board/huge bold"),
00467         anchor=gtk.ANCHOR_CENTER,
00468         text = self.value
00469         )
00470 
00471       self.background.connect("event",self.answer_event)
00472       self.background_focused.connect("event",self.answer_event)
00473       self.icone.connect("event",self.answer_event)
00474       self.text.connect("event",self.answer_event)
00475 


Member Function Documentation

def bargame.Gcompris_bargame.answer_button.answer_event (   self,
  item,
  event 
)

Definition at line 488 of file bargame.py.

00488 
00489     def answer_event(self, item, event):
00490       if ((event.type != gtk.gdk.BUTTON_PRESS) or
00491           (event.button != 1)):
00492         return False
00493 
00494       self.has_focus()
00495 
00496       value = ( (self.value
00497                  + 1
00498                  - self.number_balls[0])
00499                 % (self.number_balls[1]
00500                    + 1
00501                    - self.number_balls[0])
00502                 + self.number_balls[0]
00503                 )
00504       self.new_value(value)
00505 
00506       return True
00507 
  class prof_button:

Here is the call graph for this function:

Definition at line 480 of file bargame.py.

00480 
00481     def has_focus(self):
00482       self.background_focused.show()
00483       self.focus = True

Here is the caller graph for this function:

Definition at line 476 of file bargame.py.

00476 
00477     def new_value(self, value):
00478       self.value = value
00479       self.text.set_property('text',value)

Here is the caller graph for this function:

Definition at line 484 of file bargame.py.

00484 
00485     def set_number_of_balls(self, number_balls):
00486       self.number_balls = number_balls
00487       self.new_value(1)

Here is the call graph for this function:


Member Data Documentation

Definition at line 428 of file bargame.py.

Definition at line 438 of file bargame.py.

Definition at line 419 of file bargame.py.

Definition at line 446 of file bargame.py.

Definition at line 423 of file bargame.py.

Definition at line 421 of file bargame.py.

Definition at line 460 of file bargame.py.

Definition at line 458 of file bargame.py.


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