def on_select(value):
     #debug('on select: %s' % value)
     for kid in self.view.widgets.message_box_parent.get_children():
         self.view.widgets.remove_parent(kid)
     self.set_model_attr('genus', value)
     if not value:
         return
     syn = self.session.query(GenusSynonym).\
         filter(GenusSynonym.synonym_id == value.id).first()
     if not syn:
         self.set_model_attr('genus', value)
         return
     msg = _('The genus <b>%(synonym)s</b> is a synonym of '\
                 '<b>%(genus)s</b>.\n\nWould you like to choose '\
                 '<b>%(genus)s</b> instead?' \
                 % {'synonym': syn.synonym, 'genus': syn.genus})
     box = None
     def on_response(button, response):
         self.view.widgets.remove_parent(box)
         box.destroy()
         if response:
             self.view.widgets.sp_genus_entry.\
                 set_text(utils.utf8(syn.genus))
             self.set_model_attr('genus', syn.genus)
         else:
             self.set_model_attr('genus', value)
     box = utils.add_message_box(self.view.widgets.message_box_parent,
                                 utils.MESSAGE_BOX_YESNO)
     box.message = msg
     box.on_response = on_response
     box.show()
Ejemplo n.º 2
0
 def show_message_box(self, msg):
     """
     Show an info message in the message drop down box
     """
     self.close_message_box()
     box = utils.add_message_box(self.widgets.msg_box_parent, utils.MESSAGE_BOX_INFO)
     box.message = msg
     box.show()
Ejemplo n.º 3
0
 def show_message_box(self, msg):
     """
     Show an info message in the message drop down box
     """
     self.close_message_box()
     box = utils.add_message_box(self.widgets.msg_box_parent,
                                 utils.MESSAGE_BOX_INFO)
     box.message = msg
     box.show()
Ejemplo n.º 4
0
 def show_error_box(self, msg, details=None):
     self.close_message_box()
     box = utils.add_message_box(self.widgets.msg_box_parent, utils.MESSAGE_BOX_INFO)
     box.message = msg
     box.details = details
     colors = [("bg", gtk.STATE_NORMAL, "#FF9999"), ("bg", gtk.STATE_PRELIGHT, "#FFAAAA")]
     for color in colors:
         box.set_color(*color)
     box.show()
Ejemplo n.º 5
0
 def show_error_box(self, msg, details=None):
     self.close_message_box()
     box = utils.add_message_box(self.widgets.msg_box_parent,
                                 utils.MESSAGE_BOX_INFO)
     box.message = msg
     box.details = details
     colors = [('bg', gtk.STATE_NORMAL, '#FF9999'),
               ('bg', gtk.STATE_PRELIGHT, '#FFAAAA')]
     for color in colors:
         box.set_color(*color)
     box.show()
Ejemplo n.º 6
0
    def start(self):
        from bauble.plugins.garden.accession import Accession
        sub_editor = None
        if self.session.query(Accession).count() == 0:
            msg = 'You must first add or import at least one Accession into '\
                  'the database before you can add plants.\n\nWould you like '\
                  'to open the Accession editor?'
            if utils.yes_no_dialog(msg):
                # cleanup in case we start a new PlantEditor
                self.presenter.cleanup()
                from bauble.plugins.garden.accession import AccessionEditor
                sub_editor = AccessionEditor()
                self._commited = sub_editor.start()
        if self.session.query(Location).count() == 0:
            msg = 'You must first add or import at least one Location into '\
                  'the database before you can add species.\n\nWould you '\
                  'like to open the Location editor?'
            if utils.yes_no_dialog(msg):
                # cleanup in case we start a new PlantEditor
                self.presenter.cleanup()
                sub_editor = LocationEditor()
                self._commited = sub_editor.start()

        if self.branched_plant:
            # set title if in branch mode
            title = self.presenter.view.get_window().props.title
            self.presenter.view.get_window().props.title += \
                utils.utf8(' - %s' % _('Branch Mode'))
            message_box_parent = self.presenter.view.widgets.message_box_parent
            map(message_box_parent.remove, message_box_parent.get_children())
            msg = _('Branching from %(plant_code)s.  The quantity will '
                    'be subtracted from %(plant_code)s') \
                    % {'plant_code': str(self.branched_plant)}
            box = utils.add_message_box(message_box_parent,
                                        utils.MESSAGE_BOX_INFO)
            box.message = msg
            box.show_all()

            # don't allow editing the accession code in a branched plant
            self.presenter.view.widgets.plant_acc_entry.props.editable = False

        if not sub_editor:
            while True:
                response = self.presenter.start()
                self.presenter.view.save_state()
                if self.handle_response(response):
                    break

        self.session.close() # cleanup session
        self.presenter.cleanup()
        return self._committed
Ejemplo n.º 7
0
 def on_select(value):
     #debug('on select: %s' % value)
     for kid in self.view.widgets.message_box_parent.get_children():
         self.view.widgets.remove_parent(kid)
     self.set_model_attr('family', value)
     if not value:
         return
     syn = self.session.query(FamilySynonym).\
         filter(FamilySynonym.synonym_id == value.id).first()
     if not syn:
         self.set_model_attr('family', value)
         return
     msg = _('The family <b>%(synonym)s</b> is a synonym of '\
                 '<b>%(family)s</b>.\n\nWould you like to choose '\
                 '<b>%(family)s</b> instead?' \
                 % {'synonym': syn.synonym, 'family': syn.family})
     box = None
     def on_response(button, response):
         self.view.widgets.remove_parent(box)
         box.destroy()
         if response:
             # populate the completions model on the entry so
             # when we set the text it will match the
             # completion and set the value
             completion = self.view.widgets.gen_family_entry.\
                 get_completion()
             utils.clear_model(completion)
             model = gtk.ListStore(object)
             model.append([syn.family])
             completion.set_model(model)
             self.view.widgets.gen_family_entry.\
                 set_text(utils.utf8(syn.family))
             # the family value should be set properly when the
             # text is set on the entry but it doesn't hurt to
             # duplicate it here
             self.set_model_attr('family', syn.family)
     box = utils.add_message_box(self.view.widgets.message_box_parent,
                                 utils.MESSAGE_BOX_YESNO)
     box.message = msg
     box.on_response = on_response
     box.show()
Ejemplo n.º 8
0
 def show_yesno_box(self, msg):
     self.close_message_box()
     box = utils.add_message_box(self.widgets.msg_box_parent,
                                 utils.MESSAGE_BOX_YESNO)
     box.message = msg
     box.show()
Ejemplo n.º 9
0
 def show_yesno_box(self, msg):
     self.close_message_box()
     box = utils.add_message_box(self.widgets.msg_box_parent,
                                 utils.MESSAGE_BOX_YESNO)
     box.message = msg
     box.show()