コード例 #1
0
 def nutBoxCB (self, *args):
     txt=cb.cb_get_active_text(self.nutBox)
     row=self.db.nutrition_table[self.db.nutrition_table.find({'desc':txt})]        
     conversion =  self.nd.get_conversion_for_amt(
         float(self.amtBox.get_value()),
         cb.cb_get_active_text(self.unitBox),
         self.itmBox.get_text(),
         row)        
     myfields = filter(lambda x: x[1] in self.fields, parser_data.NUTRITION_FIELDS)
     lab = ""
     for ln,f,typ in myfields:
         amt = getattr(row,f)
         if f in parser_data.PER_100_GRAMS:
             if conversion:
                 amt = "%s"%(amt * conversion)
             else:
                 amt = "%s/%s"%(amt,_('100 grams'))
         lab += "\n%s: %s"%(ln,amt)
     self.nutLabel.set_text(lab)
コード例 #2
0
 def nutBoxCB (self, *args):
     txt=cb.cb_get_active_text(self.nutBox)
     row=self.db.nutrition_table[self.db.nutrition_table.find({'desc':txt})]        
     conversion =  self.nd.get_conversion_for_amt(
         float(self.amtBox.get_value()),
         cb.cb_get_active_text(self.unitBox),
         self.itmBox.get_text(),
         row)        
     myfields = filter(lambda x: x[1] in self.fields, parser_data.NUTRITION_FIELDS)
     lab = ""
     for ln,f,typ in myfields:
         amt = getattr(row,f)
         if f in parser_data.PER_100_GRAMS:
             if conversion:
                 amt = "%s"%(amt * conversion)
             else:
                 amt = "%s/%s"%(amt,_('100 grams'))
         lab += "\n%s: %s"%(ln,amt)
     self.nutLabel.set_text(lab)
コード例 #3
0
ファイル: DatabaseChooser.py プロジェクト: sappjw/gourmet
 def change_db_cb (self, *args):
     self.current_db = None
     text = cb.cb_get_active_text(self.dbComboBox)
     if not text:
         return
     for db in self.possible_dbs:
         if text.lower().find(db.lower()) >= 0:
             self.current_db = db
             break
     if self.current_db in self.need_connection_info:
         self.connectionExpander.set_expanded(True)
         for w in self.connection_widgets:
             getattr(self,w).show()
     else:
         for w in self.connection_widgets:
             getattr(self,w).hide()
     for w in self.file_widgets:
         if self.current_db in self.need_file_info:
             getattr(self,w).show()
         else:
             getattr(self,w).hide()
     if self.default_files.has_key(self.current_db):
         self.fileEntry.set_text(self.default_files[self.current_db])
コード例 #4
0
ファイル: nutritionView.py プロジェクト: marmistrz/gourmet
 def get_choice (self, choiceWidget):
     """Return the user's current choice from choiceWidget"""
     return cb.cb_get_active_text(choiceWidget)
コード例 #5
0
ファイル: nutritionView.py プロジェクト: marmistrz/gourmet
 def get_active_usda (self):
     return cb.cb_get_active_text(self.usdaChoiceWidget)
コード例 #6
0
 def get_choice (self, choiceWidget):
     """Return the user's current choice from choiceWidget"""
     return cb.cb_get_active_text(choiceWidget)
コード例 #7
0
 def get_active_usda (self):
     return cb.cb_get_active_text(self.usdaChoiceWidget)