Exemplo n.º 1
0
    def __init__(self, app, parent):
        self.ui = food_win_ui.FoodWinUI()
        self.app = app
        self.parent = parent

        self.nutr_comp_dlg = nutr_composition_dlg.NutrCompositionDlg()
        self.ui.hbox = self.nutr_comp_dlg.ui.hbox
        self.ui.hbox.reparent(self.ui.notebook_container)
        self.ui.notebook_container.show_all()
        self.store = store.Store()

        self.connect_signals()
Exemplo n.º 2
0
 def on_save_as_activate(self, w, d=None):
     recipe = self.get_recipe()
     if not hasattr(self, 'file_select_dlg'):
         import file_select_dlg
         self.file_select_dlg = file_select_dlg.FileSelectDlg()
     if recipe:
         if not hasattr(self, 'nutr_composition_dlg'):
             import nutr_composition_dlg
             self.nutr_composition_dlg = \
                 nutr_composition_dlg.NutrCompositionDlg()
         nutr_list = self.nutr_composition_dlg.compute_nutr_total(recipe)
         pcnt_cal = self.nutr_composition_dlg.compute_pcnt_calories()
         self.file_select_dlg.show(recipe, nutr_list, pcnt_cal)
Exemplo n.º 3
0
    def on_nutr_released(self, w, d=None):
        if self.num_ingr == 0:
            gnutr.Dialog('warn', 'There are no ingredients.', self.parent)
            return
        num_serv = self.ui.num_serv_entry.get_text()
        try:
            num = int(num_serv)
        except ValueError:
            gnutr.Dialog(
                'warn', """The number of servings in not specified +
or is not a number.""", self.parent)
            return
        r = self.get_recipe()
        if not r:
            return
        if not hasattr(self, 'nutr_composition_dlg'):
            import nutr_composition_dlg
            self.nutr_composition_dlg = \
                nutr_composition_dlg.NutrCompositionDlg()
        self.nutr_composition_dlg.show(recipe=r)
Exemplo n.º 4
0
    def on_response(self, w, r, d=None):
        if r == gtk.RESPONSE_HELP:
            help.open('')

        elif r == 1:
            start_date = self.ui.start_date.entry.get_text()
            end_date = self.ui.end_date.entry.get_text()
            if self.start_later_than_end(start_date, end_date):
                gnutr.Dialog(
                    'error',
                    'The start date is later\n' + 'than the end date.')
                return

            avg = self.ui.avg_rad_button.get_active()
            result = self.compute(start_date, end_date, avg)
            if not hasattr(self, 'nutr_composition_dlg'):
                import nutr_composition_dlg
                self.nutr_composition_dlg = \
                    nutr_composition_dlg.NutrCompositionDlg()
            self.nutr_composition_dlg.show(nutr_list=result)

        elif r == gtk.RESPONSE_CANCEL or r == gtk.RESPONSE_DELETE_EVENT:
            self.ui.dialog.hide()