Exemplo n.º 1
0
 def on_accept_incoming(self, menu_item):
     ka_debug.info('on_accept_incoming [%s]' % menu_item.parent.name)
     protozoon = self.accept_protozoon(
         ka_controller.name_to_index(menu_item.parent.name))
     if protozoon is not None:
         new_at = self._parent.model.replace(protozoon.copy())
         self._parent.start_calculation([new_at])
Exemplo n.º 2
0
 def on_zoom_incoming(self, menu_item):
     #        ka_debug.info('on_zoom_incoming [%s]' % menu_item.parent.name)
     zoom_controller = self._parent._controller.find_page('ZoomController')
     if zoom_controller is not None:
         index = ka_controller.name_to_index(menu_item.parent.name)
         protozoon, dummy = self.at_index(index)
         zoom_controller.start_calculation(protozoon)
Exemplo n.º 3
0
 def on_favorite_activate(self, *args):
     """Set best ranking for this protozoon.
     pre: len(args) >= 1
     """
     #        ka_debug.info('on_favorite_activate [%s]' % args[0].get_name())
     self.model.raise_fitness(
         ka_controller.name_to_index(args[0].get_name()))
     self._update_population_gui()
Exemplo n.º 4
0
 def on_incomingarea_expose(self, widget, dummy):
     """ Repaint image of a single protozoon inside incoming area.
     pre: widget is not None
     """
     #        ka_debug.info('incoming: on_incomingarea_expose: ' + widget.name)
     self.draw(ka_controller.name_to_index(widget.name), \
                        ka_controller.create_context(widget), \
                        widget.allocation.width, widget.allocation.height)
Exemplo n.º 5
0
 def on_explain_activate(self, *args):
     """Publish single protozoon to all other buddies.
     pre: len(args) >= 1
     """
     ka_debug.info('on_explain_activate [%s]' % args[0].get_name())
     details_controller = self._controller.find_page('DetailsController')
     if details_controller is not None:
         pix = ka_controller.name_to_index(args[0].get_name())
         details_controller.start_calculation(self.model.protozoans[pix])
Exemplo n.º 6
0
 def on_publishprotozoon_activate(self, *args):
     """Publish single protozoon to all other buddies.
     pre: len(args) >= 1
     """
     ka_debug.info('on_publishprotozoon_activate [%s]' % args[0].get_name())
     if self._tube:
         proto = self.model.protozoans[ka_controller.name_to_index(
             args[0].get_name())]
         self._tube.publish_protozoon(model_population.to_buffer(proto))
Exemplo n.º 7
0
 def on_fitness_value_changed(self, *args):
     """
     pre: len(args) >= 1
     """
     #        ka_debug.info('on_fitness_value_changed %f [%s]' %
     #                   (args[0].get_value(), args[0].get_name()))
     self.model.fitness[ka_controller.name_to_index(args[0].get_name())] \
         = args[0].get_value()
     self._update_population_gui()
Exemplo n.º 8
0
 def on_drawingarea_size_allocate(self, widget, event):
     """ New size for drawing area available.
     pre: widget is not None
     """
     #        ka_debug.info('on_drawingarea_size_allocate: ' + widget.name + ' '
     #                      + str(widget.allocation.width)
     #                      + 'x' + str(widget.allocation.height))
     if self.model is not None:
         self.start_calculation([ka_controller.name_to_index(widget.name)])
Exemplo n.º 9
0
 def on_drawingarea_expose(self, widget, event):
     """ Repaint image of a single protozoon inside population area.
     pre: widget is not None
     """
     # draw precalculated protozoon stored in the surface cache.
     #        ka_debug.info('on_drawingarea_expose: ' + widget.name + ' '
     #                      + str(widget.allocation.width)
     #                      + 'x' + str(widget.allocation.height))
     self._draw_from_cache(widget, ka_controller.name_to_index(widget.name))
Exemplo n.º 10
0
 def on_awfull_activate(self, *args):
     """Set last ranking for this protozoon.
     pre: len(args) >= 1
     """
     #        ka_debug.info('on_awfull_activate [%s]' % args[0].get_name())
     index = ka_controller.name_to_index(args[0].get_name())
     self.model.reduce_fitness(index)
     self._update_population_gui()
     ka_task.GeneratorTask(self.task_breed_single, self.on_model_completed,
                           args[0].get_name()).start(index)
Exemplo n.º 11
0
 def _show_popup(self, widget, event, menu):
     #        ka_debug.info('%s [%s]' % (menu, widget.name))
     index = ka_controller.name_to_index(menu)
     self._widget_list.get_widget('favorite_menuitem_' + str(index)). \
                         set_sensitive(self.model.fitness[index] < 9.0)
     dummy, moderate, dummy = self.model.classify()
     is_sensitive = len(moderate) > 0
     self._widget_list.get_widget('awfull_menuitem_' + str(index)). \
                         set_sensitive(is_sensitive)
     popup_menu = self._widget_list.get_widget(menu)
     popup_menu.popup(None, None, None, event.button, event.time)
Exemplo n.º 12
0
 def on_exportpng_activate(self, *args):
     """Publish single protozoon to all other buddies.
     pre: len(args) >= 1
     """
     ka_debug.info('on_exportpng_activate [%s]' % args[0].get_name())
     pix = ka_controller.name_to_index(args[0].get_name())
     exporter = ka_extensionpoint.create('exporter_png',
                                         self.model.protozoans[pix],
                                         self._activity_root)
     preference = ka_preference.Preference.instance()
     export_size = preference.get(ka_preference.EXPORT_SIZE)
     exporter.export(*export_size)
Exemplo n.º 13
0
 def on_protozoon_popup(self, widget, event):
     #        ka_debug.info('on_protozoon_popup: ' + widget.name)
     self._show_popup(widget, event, \
                      'protozoon_menu_%u' % ka_controller.name_to_index(widget.name))
Exemplo n.º 14
0
 def on_decline_incoming(self, menu_item):
     ka_debug.info('on_decline_incoming [%s]' % menu_item.parent.name)
     self.decline_protozoon(
         ka_controller.name_to_index(menu_item.parent.name))
Exemplo n.º 15
0
 def on_incoming_popup(self, widget, event):
     ka_debug.info('on_incoming_popup: ' + widget.name)
     index = ka_controller.name_to_index(widget.name)
     self._show_popup(widget, event, 'incoming_menu_' + str(index))