def __init__(self, canvas, lessons_path, images_path, sounds_path, parent=None): ''' The general stuff we need to track ''' self._activity = parent self._lessons_path = lessons_path self._images_path = images_path self._sounds_path = sounds_path self._colors = profile.get_color().to_string().split(',') self._card_data = [] self._color_data = [] self._image_data = [] self._media_data = [] # (image sound, letter sound) self._word_data = [] self._deja_vu = [] # Starting from command line if self._activity is None: self._sugar = False self._canvas = canvas else: self._sugar = True self._canvas = canvas self._activity.show_all() self._canvas.add_events(Gdk.EventMask.BUTTON_PRESS_MASK) self._canvas.add_events(Gdk.EventMask.BUTTON_RELEASE_MASK) self._canvas.connect("draw", self.__draw_cb) self._canvas.connect("button-press-event", self._button_press_cb) self._canvas.connect("button-release-event", self._button_release_cb) self._canvas.connect("key_press_event", self._keypress_cb) self._width = Gdk.Screen.width() self._height = Gdk.Screen.height() self._card_width = int((self._width / XDIM)) - GUTTER * 2 self._card_height = int((self._height - GRID_CELL_SIZE) / YDIM) \ - GUTTER * 2 self._grid_x_offset = int( (self._width - XDIM * (self._card_width + GUTTER * 2)) / 2) self._grid_y_offset = 0 self._scale = self._card_width / 80. self._sprites = Sprites(self._canvas) self.current_card = 0 self._cards = [] self._pictures = [] self._press = None self._release = None self.timeout = None self._my_canvas = Sprite( self._sprites, 0, 0, svg_str_to_pixbuf(genblank( self._width, self._height, (self._colors[0], self._colors[0])))) self._my_canvas.type = 'background' self.load_level(os.path.join(self._lessons_path, 'alphabet' + '.csv')) self.new_page()
def __init__(self, canvas, lessons_path, images_path, sounds_path, parent=None): ''' The general stuff we need to track ''' self._activity = parent self._lessons_path = lessons_path self._images_path = images_path self._sounds_path = sounds_path self._colors = profile.get_color().to_string().split(',') self._card_data = [] self._color_data = [] self._image_data = [] self._word_data = [] self.chosen_image = None # Starting from command line if self._activity is None: self._sugar = False self._canvas = canvas else: self._sugar = True self._canvas = canvas self._activity.show_all() self._canvas.add_events(Gdk.EventMask.BUTTON_PRESS_MASK) self._canvas.add_events(Gdk.EventMask.BUTTON_RELEASE_MASK) self._canvas.connect("draw", self.__draw_cb) self.button_release_event_id = \ self._canvas.connect("button-release-event", self._button_release_cb) self.button_press_event_id = \ self._canvas.connect("button-press-event", self._button_press_cb) self._canvas.connect("key_press_event", self._keypress_cb) self._width = Gdk.Screen.width() self._height = Gdk.Screen.height() self._card_height = int((self._height - GRID_CELL_SIZE) / YDIM) \ - GUTTER * 2 self._card_width = int(self._card_height * 4 / 3.) self._grid_x_offset = int( (self._width - XDIM * (self._card_width + GUTTER * 2)) / 2) self._grid_y_offset = 0 self._scale = self._card_width / 80. self._sprites = Sprites(self._canvas) self.current_card = 0 self._cards = [] self._pictures = [] self._press = None self._release = None self.timeout = None self.target = 0 self.answers = [] self._my_canvas = Sprite( self._sprites, 0, 0, svg_str_to_pixbuf( genblank(self._width, self._height, (self._colors[0], self._colors[0])))) self._my_canvas.type = 'background' self._smile = Sprite( self._sprites, int(self._width / 4), int(self._height / 4), GdkPixbuf.Pixbuf.new_from_file_at_size( os.path.join(self._activity.activity_path, 'images', 'correct.png'), int(self._width / 2), int(self._height / 2))) self._frown = Sprite( self._sprites, int(self._width / 4), int(self._height / 4), GdkPixbuf.Pixbuf.new_from_file_at_size( os.path.join(self._activity.activity_path, 'images', 'wrong.png'), int(self._width / 2), int(self._height / 2))) self.load_level(os.path.join(self._lessons_path, 'alphabet' + '.csv')) # Create the cards we'll need self._alpha_cards() self.load_from_journal(self._activity.data_from_journal) self.new_page()
def __init__(self, canvas, lessons_path, images_path, sounds_path, parent=None): ''' The general stuff we need to track ''' self._activity = parent self._lessons_path = lessons_path self._images_path = images_path self._sounds_path = sounds_path self._colors = profile.get_color().to_string().split(',') self._card_data = [] self._color_data = [] self._image_data = [] self._word_data = [] self.chosen_image = None # Starting from command line if self._activity is None: self._sugar = False self._canvas = canvas else: self._sugar = True self._canvas = canvas self._activity.show_all() self._canvas.add_events(Gdk.EventMask.BUTTON_PRESS_MASK) self._canvas.add_events(Gdk.EventMask.BUTTON_RELEASE_MASK) self._canvas.connect("draw", self.__draw_cb) self.button_release_event_id = \ self._canvas.connect("button-release-event", self._button_release_cb) self.button_press_event_id = \ self._canvas.connect("button-press-event", self._button_press_cb) self._canvas.connect("key_press_event", self._keypress_cb) self._width = Gdk.Screen.width() self._height = Gdk.Screen.height() self._card_height = int((self._height - GRID_CELL_SIZE) / YDIM) \ - GUTTER * 2 self._card_width = int(self._card_height * 4 / 3.) self._grid_x_offset = int( (self._width - XDIM * (self._card_width + GUTTER * 2)) / 2) self._grid_y_offset = 0 self._scale = self._card_width / 80. self._sprites = Sprites(self._canvas) self.current_card = 0 self._cards = [] self._pictures = [] self._press = None self._release = None self.timeout = None self.target = 0 self.answers = [] self._my_canvas = Sprite( self._sprites, 0, 0, svg_str_to_pixbuf(genblank( self._width, self._height, (self._colors[0], self._colors[0])))) self._my_canvas.type = 'background' self._smile = Sprite(self._sprites, int(self._width / 4), int(self._height / 4), GdkPixbuf.Pixbuf.new_from_file_at_size( os.path.join(self._activity.activity_path, 'images', 'correct.png'), int(self._width / 2), int(self._height / 2))) self._frown = Sprite(self._sprites, int(self._width / 4), int(self._height / 4), GdkPixbuf.Pixbuf.new_from_file_at_size( os.path.join(self._activity.activity_path, 'images', 'wrong.png'), int(self._width / 2), int(self._height / 2))) self.load_level(os.path.join(self._lessons_path, 'alphabet' + '.csv')) # Create the cards we'll need self._alpha_cards() self.load_from_journal(self._activity.data_from_journal) self.new_page()