def __init__(self, default_value=inch): Gtk.HBox.__init__(self) # do we really inherit from HBox? self.__quiet__ = False self.unit_combo = Gtk.ComboBoxText() for key in self.units: self.unit_combo.append_text(key) unit = get_prefs().get('default_margin_unit', _('cm')) if unit not in self.units: unit = _('cm') self.last_unit = self.units[unit] cb_extras.setup_typeahead(self.unit_combo) cb_extras.cb_set_active_text(self.unit_combo, unit) self.unit_combo.connect('changed', self.unit_changed_cb) self.value_adjustment = Gtk.Adjustment( value=self.adjust_to_unit(default_value), lower=self.min_val / self.last_unit, upper=self.max_val / self.last_unit, step_incr=self.adjustments[self.last_unit][0], page_incr=self.adjustments[self.last_unit][1], ) def emit_changed(*args): self.emit('changed') self.value_adjustment.connect('changed', emit_changed) self.value_widget = Gtk.SpinButton(self.value_adjustment, digits=2) self.value_widget.connect('changed', emit_changed) self.value_widget.show() self.unit_combo.show() self.pack_start(self.value_widget, True, True, 0) self.pack_start(self.unit_combo, True, True, 0)
def set_search(self, txt): """Set the search to txt, ensuring there are results. If there are no results for the search, we'll try a partial search for only some of the words in txt. If that fails, we'll set the search to blank. """ words = re.split(r'\W+', txt) # always search raw if possible... (it gets us the real thing # vs. canned/frozen/soup/babyfood, etc.) if 'raw' not in words: words += ['raw'] search_terms = [] search_in = self.rd.nutrition_table srch = [] searchvw = None for w in words: if w in [',', ' ', ';', '.']: continue result = self.rd.search_nutrition(srch + [w]) if result: srch += [w] searchvw = result groups = self.rd.fetch_food_groups_for_search(srch) cur_active = cb.cb_get_active_text(self.foodGroupComboBox) groups = [self.ALL_GROUPS] + groups cb.set_model_from_list(self.foodGroupComboBox, groups) cb.cb_set_active_text(self.foodGroupComboBox, cur_active) self.__override_search__ = True # turn off any handling of text insertion search_text = ' '.join(srch) self.usdaSearchEntry.set_text(search_text) self.searchvw = searchvw or self.rd.fetch_all(self.rd.nutrition_table) self.nutrition_store.change_view(self.searchvw) self.__last_search__ = search_text self.__override_search__ = False # turn back on search handling!
def set_search (self, txt): """Set the search to txt, ensuring there are results. If there are no results for the search, we'll try a partial search for only some of the words in txt. If that fails, we'll set the search to blank. """ words = re.split('\W+',txt) # always search raw if possible... (it gets us the real thing # vs. canned/frozen/soup/babyfood, etc.) if 'raw' not in words: words += ['raw'] search_terms = [] search_in = self.rd.nutrition_table srch = [] searchvw = None for w in words: if w in [',',' ',';','.']: continue result = self.rd.search_nutrition(srch+[w]) if result: srch += [w] searchvw = result groups = self.rd.fetch_food_groups_for_search(srch) cur_active = cb.cb_get_active_text(self.foodGroupComboBox) groups = [self.ALL_GROUPS] + groups cb.set_model_from_list(self.foodGroupComboBox,groups) cb.cb_set_active_text(self.foodGroupComboBox,cur_active) self.__override_search__ = True # turn off any handling of text insertion search_text = ' '.join(srch) self.usdaSearchEntry.set_text(search_text) self.searchvw = searchvw or self.rd.fetch_all(self.rd.nutrition_table) self.nutrition_store.change_view(self.searchvw) self.__last_search__ = search_text self.__override_search__ = False # turn back on search handling!
def __init__(self, rd, prefs, widgets): self.rd = rd self.prefs = prefs for name, w in widgets: setattr(self, name, w) self._setup_nuttree_() self.__last_search__ = '' self.__override_search__ = False # TODO: Fixing saving usdaSearchAsYouTypeToggle state # Button state is not being saved across sessions and always starts off # inactive. Of note, this problem seemed to also exist in the last # release (0.17.4), but the button always started off active. WidgetSaver.WidgetSaver(self.usdaSearchAsYouTypeToggle, self.prefs.get('sautTog', {'active': True}), ['toggled']) # Ensure usdaFindButton is shown if usdaSearchAsYouTypeToggle is # inactive self.toggle_saut() # search self.usdaSearchEntry.connect('changed', self.search_type_cb) self.usdaFindButton.connect('clicked', self.search_cb) self.usdaSearchAsYouTypeToggle.connect('toggled', self.toggle_saut) cb.set_model_from_list( self.foodGroupComboBox, [self.ALL_GROUPS] + self.rd.get_unique_values('foodgroup', self.rd.nutrition_table)) cb.cb_set_active_text(self.foodGroupComboBox, self.ALL_GROUPS)
def __init__(self): self.init_player() self.ui = Gtk.Builder() self.ui.add_from_file(os.path.join(gglobals.uibase, 'timerDialog.ui')) self.timer = TimeSpinnerUI(self.ui.get_object('hoursSpinButton'), self.ui.get_object('minutesSpinButton'), self.ui.get_object('secondsSpinButton')) self.timer.connect_timer_hook(self.timer_done_cb) for w in [ 'timerDialog', 'mainLabel', 'soundComboBox', 'repeatCheckButton', 'noteEntry', 'expander1', 'timerBox', 'resetTimerButton', 'timerFinishedLabel', 'keepAnnoyingLabel' ]: setattr(self, w, self.ui.get_object(w)) cb.set_model_from_list(self.soundComboBox, list(self.sounds_and_files.keys())) cb.cb_set_active_text(self.soundComboBox, _('Ringing Sound')) self.ui.connect_signals({ 'reset_cb': self.timer.reset_cb, 'pause_cb': self.timer.pause_cb, 'start_cb': self.timer.start_cb, 'note_changed_cb': self.note_changed_cb, }) self.timerDialog.connect('response', self.response_cb) self.timerDialog.connect('close', self.close_cb) self.timerDialog.set_modal(False) self.note = ''
def __init__ (self, default_value = inch): gobject.GObject.__init__(self) gtk.HBox.__init__(self) self.__quiet__ = False self.unit_combo = gtk.combo_box_new_text() for key in self.units: self.unit_combo.append_text(key) unit = get_prefs().get('default_margin_unit',_('cm')) if unit not in self.units: unit = _('cm') self.last_unit = self.units[unit] cb_extras.setup_typeahead(self.unit_combo) cb_extras.cb_set_active_text(self.unit_combo,unit) self.unit_combo.connect('changed',self.unit_changed_cb) self.value_adjustment = gtk.Adjustment( value=self.adjust_to_unit(default_value), lower= self.min_val / self.last_unit, upper = self.max_val / self.last_unit, step_incr = self.adjustments[self.last_unit][0], page_incr = self.adjustments[self.last_unit][1], ) def emit_changed (*args): self.emit('changed') self.value_adjustment.connect('changed',emit_changed) self.value_widget = gtk.SpinButton(self.value_adjustment,digits=2) self.value_widget.connect('changed',emit_changed) self.value_widget.show(); self.unit_combo.show() self.pack_start(self.value_widget) self.pack_start(self.unit_combo)
def set_limit(self, ingredients, in_string=_('recipe')): """Set ingredients to show in index. in_string is a string describing what these ingredients represent. For example, recipe. """ self.ingredients = ingredients self.in_string = in_string cb.set_model_from_list( self.nutritionFilterComboBox, [self.in_string, _('entire database')]) cb.cb_set_active_text(self.nutritionFilterComboBox, self.in_string)
def set_limit (self, ingredients, in_string=_('recipe')): """Set ingredients to show in index. in_string is a string describing what these ingredients represent. For example, recipe. """ self.ingredients = ingredients self.in_string = in_string cb.set_model_from_list( self.nutritionFilterComboBox, [self.in_string,_('entire database')] ) cb.cb_set_active_text(self.nutritionFilterComboBox,self.in_string)
def _setup_custom_box(self): """Setup the interface for entering custom nutritional information. """ t = gtk.Table() masses = [i[0] for i in defaults.UNIT_GROUPS['metric mass']\ + defaults.UNIT_GROUPS['imperial weight']] cb.set_model_from_list(self.massUnitComboBox, masses) cb.cb_set_active_text(self.massUnitComboBox, 'g') self.customNutritionAmountEntry.set_value(100) self.nutrition_info = {} self.custom_box.add(t) self.changing_percent_internally = False self.changing_number_internally = False l = gtk.Label('%RDA') l.show() t.attach(l, 2, 3, 0, 1) for n, nutstuff in enumerate(NUT_LAYOUT): if nutstuff == SEP: hs = gtk.HSeparator() t.attach(hs, 0, 2, n + 1, n + 2, xoptions=gtk.FILL) hs.show() continue label_txt, typ, name, properties, show_percent, unit = nutstuff if unit: label_txt += " (" + unit + ")" label = gtk.Label(label_txt) label.show() label.set_alignment(0, 0.5) t.attach(label, 0, 1, n + 1, n + 2, xoptions=gtk.FILL) entry = NumberEntry(default_to_fractions=False) entry.show() t.attach(entry, 1, 2, n + 1, n + 2, xoptions=gtk.FILL) if show_percent: percent_entry = NumberEntry(default_to_fractions=False, decimals=0) percent_entry.entry.set_width_chars(4) percent_entry.show() percent_label = gtk.Label('%') percent_label.show() t.attach(percent_entry, 2, 3, n + 1, n + 2) t.attach(percent_label, 3, 4, n + 1, n + 2) percent_label.set_alignment(0, 0.5) percent_entry.connect('changed', self.percent_changed_cb, name, entry) percent_entry.entry.set_width_chars(5) else: percent_entry = None entry.connect('changed', self.number_changed_cb, name, percent_entry) t.set_row_spacings(6) t.set_col_spacings(12) t.show()
def info_edit_equivalent (self, button, eq): """Edit equivalents callback. eq is a nutalias DB object. """ self.amounts[self.ingkey] = {} self.amount = 1 self.ingkey = self.info_nutalias.ingkey self.set_from_unit(eq.unit) self.fromAmountEntry.set_text('1') conv = self.nd.get_conversion_for_amt(1,eq.unit,self.info_nutalias.ingkey) amt_in_grams = conv * 100 self.setup_to_units() to_unit = cb.cb_set_active_text(self.toUnitCombo,'g') self.toAmountEntry.set_text(convert.float_to_frac(amt_in_grams, fractions=convert.FRACTIONS_ASCII )) # Hack to avoid adding ourselves to the path on a "back" event # -- if button is None, then we know we were called # artificially from previous_page_cb (not from a button press # event) if button: self.path.append( (self.info_edit_equivalent, [None,eq]) ) self.goto_page_unit_convert()
def _setup_custom_box (self): """Setup the interface for entering custom nutritional information. """ t = gtk.Table() masses = [i[0] for i in defaults.UNIT_GROUPS['metric mass']\ + defaults.UNIT_GROUPS['imperial weight']] cb.set_model_from_list( self.massUnitComboBox, masses) cb.cb_set_active_text(self.massUnitComboBox,'g') self.customNutritionAmountEntry.set_value(100) self.nutrition_info = {} self.custom_box.add(t) self.changing_percent_internally = False self.changing_number_internally = False l=gtk.Label('%RDA'); l.show() t.attach(l,2,3,0,1) for n,nutstuff in enumerate(NUT_LAYOUT): if nutstuff == SEP: hs = gtk.HSeparator() t.attach(hs,0,2,n+1,n+2,xoptions=gtk.FILL) hs.show() continue label_txt,typ,name,properties,show_percent,unit = nutstuff if unit: label_txt += " (" + unit + ")" label = gtk.Label(label_txt); label.show() label.set_alignment(0,0.5) t.attach(label,0,1,n+1,n+2,xoptions=gtk.FILL) entry = NumberEntry(default_to_fractions=False) entry.show() t.attach(entry,1,2,n+1,n+2,xoptions=gtk.FILL) if show_percent: percent_entry = NumberEntry(default_to_fractions=False, decimals=0) percent_entry.entry.set_width_chars(4) percent_entry.show() percent_label = gtk.Label('%'); percent_label.show() t.attach(percent_entry,2,3,n+1,n+2) t.attach(percent_label,3,4,n+1,n+2) percent_label.set_alignment(0,0.5) percent_entry.connect('changed',self.percent_changed_cb,name,entry) percent_entry.entry.set_width_chars(5) else: percent_entry = None entry.connect('changed',self.number_changed_cb,name,percent_entry) t.set_row_spacings(6) t.set_col_spacings(12) t.show()
def search(self): txt = self.usdaSearchEntry.get_text() if self.__last_search__ == txt and self.group == self.__last_group__: return words = re.split(r'\W+', txt) groups = self.rd.fetch_food_groups_for_search(words) cur_active = cb.cb_get_active_text(self.foodGroupComboBox) groups = [self.ALL_GROUPS] + groups if cur_active not in groups: groups += [cur_active] cb.set_model_from_list(self.foodGroupComboBox, groups) cb.cb_set_active_text(self.foodGroupComboBox, cur_active) self.searchvw = self.rd.search_nutrition(words, group=self.group) self.__last_search__ = txt self.__last_group__ = self.group self.nutrition_store.change_view(self.searchvw) self.nutrition_store.set_page(0)
def search (self): txt = self.usdaSearchEntry.get_text() if self.__last_search__ == txt and self.group == self.__last_group__: return words = re.split('\W+',txt) groups = self.rd.fetch_food_groups_for_search(words) cur_active = cb.cb_get_active_text(self.foodGroupComboBox) groups = [self.ALL_GROUPS] + groups if cur_active not in groups: groups += [cur_active] cb.set_model_from_list(self.foodGroupComboBox,groups) cb.cb_set_active_text(self.foodGroupComboBox,cur_active) self.searchvw = self.rd.search_nutrition(words,group=self.group) self.__last_search__ = txt self.__last_group__ = self.group self.nutrition_store.change_view(self.searchvw) self.nutrition_store.set_page(0)
def __init__(self, rd, prefs, widgets): self.rd = rd self.prefs = prefs for name, w in widgets: setattr(self, name, w) self._setup_nuttree_() self.__last_search__ = '' self.__override_search__ = False WidgetSaver.WidgetSaver(self.usdaSearchAsYouTypeToggle, self.prefs.get('sautTog', {'active': True}), ['toggled']) # search self.usdaSearchEntry.connect('changed', self.search_type_cb) self.usdaFindButton.connect('clicked', self.search_cb) self.usdaSearchAsYouTypeToggle.connect('toggled', self.toggle_saut) cb.set_model_from_list( self.foodGroupComboBox, [self.ALL_GROUPS] + self.rd.get_unique_values('foodgroup', self.rd.nutrition_table)) cb.cb_set_active_text(self.foodGroupComboBox, self.ALL_GROUPS)
def __init__ (self, rd, prefs, widgets): self.rd = rd; self.prefs = prefs for name,w in widgets: setattr(self,name,w) self._setup_nuttree_() self.__last_search__ = '' self.__override_search__ = False WidgetSaver.WidgetSaver( self.usdaSearchAsYouTypeToggle, self.prefs.get('sautTog', {'active':True}), ['toggled']) # search self.usdaSearchEntry.connect('changed',self.search_type_cb) self.usdaFindButton.connect('clicked',self.search_cb) self.usdaSearchAsYouTypeToggle.connect('toggled',self.toggle_saut) cb.set_model_from_list(self.foodGroupComboBox, [self.ALL_GROUPS]+self.rd.get_unique_values('foodgroup',self.rd.nutrition_table) ) cb.cb_set_active_text(self.foodGroupComboBox,self.ALL_GROUPS)
def label_range(self, st, end, label): if self.tags_by_label.get(label, '') == 'ignore': midno = self.hide_range(st, end) b = Gtk.Button(label='Ignored text: Reveal hidden text') anchor = self.insert_widget(end, b) def unhide_text(*args): self.unhide_area(midno) self.remove_widget(anchor) b.connect('clicked', unhide_text) b.show() return if label in self.label_counts: count = self.label_counts[label] self.label_counts[label] += 1 else: self.label_counts[label] = 1 count = 0 smark = Gtk.TextMark.new(f'{label}-{count}-start', True) emark = Gtk.TextMark.new(f'{label}-{count}-end', False) self.tb.add_mark(smark, st) self.tb.add_mark(emark, end) self.labelled.append((smark, emark)) # Now we add the labels... start_txt = '[' start_id = self.insert_markup_text(st, start_txt, self.markup_tag) # Now move the mark back up... new_pos = self.tb.get_iter_at_mark(smark) new_pos.forward_chars(len(start_txt)) self.tb.move_mark(smark, new_pos) # Create a "Remove me" button #b = Gtk.Button('_Remove tag'); b.show)( b = Gtk.Button() img = Gtk.Image.new_from_icon_name(Gtk.STOCK_REMOVE, Gtk.IconSize.MENU) b.add(img) img.show() itr = self.tb.get_iter_at_mark(emark) anchor = self.insert_widget(itr, b) # Set up combo button... labelbutton = Gtk.ComboBoxText.new() labelbutton.set_model(self.action_model) cb.cb_set_active_text(labelbutton, label) anchor2 = self.insert_widget(self.tb.get_iter_at_mark(smark), labelbutton) # Add final bracket for end of markup end_bracket_itr = self.tb.get_iter_at_mark(emark) end_id = self.insert_markup_text(end_bracket_itr, ']', self.markup_tag) self.markup_partners[start_id] = end_id self.markup_partners[end_id] = start_id # Now back up our itr one character (it got advanced by adding # the right bracket and the button) eitr = self.tb.get_iter_at_mark(emark) eitr.backward_chars(2) self.tb.move_mark(emark, eitr) # Define callback to remove our text when button is clicked def remove_markup(*args): self.labelled.remove((smark, emark)) self.remove_markup_text(start_id) self.remove_markup_text(end_id) self.remove_widget(anchor) self.remove_widget(anchor2) def change_mark(cb): # copy marks for safekeeping... new_text = cb.get_active_text() sm = Gtk.TextMark.new(None, True) self.tb.add_mark(sm, self.tb.get_iter_at_mark(smark)) em = Gtk.TextMark.new(None, False) self.tb.add_mark(em, self.tb.get_iter_at_mark(emark)) # remove old marks... remove_markup() # And relabel! self.label_range(self.tb.get_iter_at_mark(sm), self.tb.get_iter_at_mark(em), new_text) labelbutton.connect('changed', change_mark) b.connect('clicked', remove_markup)
def set_unit(self, unit): cb_extras.cb_set_active_text(self.unit_combo, unit)
def label_range (self, st, end, label): if self.tags_by_label.get(label,'')=='ignore': midno = self.hide_range(st,end) b = gtk.Button('Ignored text: Reveal hidden text') anchor = self.insert_widget(end,b) def unhide_text (*args): self.unhide_area(midno) self.remove_widget(anchor) b.connect('clicked',unhide_text) b.show() return if self.label_counts.has_key(label): count = self.label_counts[label] self.label_counts[label] += 1 else: self.label_counts[label] = 1 count = 0 smark = gtk.TextMark(label+'-'+str(count)+'-start',True) emark = gtk.TextMark(label+'-'+str(count)+'-end',False) self.tb.add_mark(smark,st) self.tb.add_mark(emark,end) self.labelled.append((smark,emark)) # Now we add the labels... start_txt = '[' start_id = self.insert_markup_text(st,start_txt,self.markup_tag) # Now move the mark back up... new_pos = self.tb.get_iter_at_mark(smark); new_pos.forward_chars(len(start_txt)) self.tb.move_mark(smark,new_pos) # Create a "Remove me" button #b = gtk.Button('_Remove tag'); b.show)( b = gtk.Button() i = gtk.Image(); i.set_from_stock(gtk.STOCK_REMOVE,gtk.ICON_SIZE_MENU) b.add(i); i.show() itr = self.tb.get_iter_at_mark(emark) anchor = self.insert_widget(itr,b) # Set up combo button... labelbutton = gtk.combo_box_new_text() labelbutton.set_model(self.action_model) cb.cb_set_active_text(labelbutton,label) anchor2 = self.insert_widget(self.tb.get_iter_at_mark(smark),labelbutton) # Add final bracket for end of markup end_bracket_itr = self.tb.get_iter_at_mark(emark) end_id = self.insert_markup_text(end_bracket_itr,']',self.markup_tag) self.markup_partners[start_id]=end_id; self.markup_partners[end_id]=start_id # Now back up our itr one character (it got advanced by adding # the right bracket and the button) eitr = self.tb.get_iter_at_mark(emark) eitr.backward_chars(2) self.tb.move_mark(emark,eitr) # Define callback to remove our text when button is clicked def remove_markup (*args): self.labelled.remove((smark,emark)) self.remove_markup_text(start_id) self.remove_markup_text(end_id) self.remove_widget(anchor) self.remove_widget(anchor2) def change_mark (cb): # copy marks for safekeeping... new_text = cb.get_active_text() sm = gtk.TextMark(None,True) self.tb.add_mark(sm,self.tb.get_iter_at_mark(smark)) em = gtk.TextMark(None,False) self.tb.add_mark(em,self.tb.get_iter_at_mark(emark)) # remove old marks... remove_markup() # And relabel! self.label_range( self.tb.get_iter_at_mark(sm), self.tb.get_iter_at_mark(em), new_text ) labelbutton.connect('changed',change_mark) b.connect('clicked',remove_markup)
def set_unit (self, unit): cb_extras.cb_set_active_text(self.unit_combo,unit)
def __init__(self, converter=convert.get_converter(), unitModel=None, amt1=None, unit1=None, item=None, okcb=None): self.possible_conversions = None self.ui = gtk.Builder() self.ui.add_from_file(os.path.join(current_path, 'converter.ui')) self.conv = converter self.changing_item = False self.okcb = okcb self.widget_names = [ 'window', 'amt1Entry', 'amt2Label', 'unit1ComboBox', 'unit2ComboBox', 'itemComboBox', 'densitySpinButton', 'useDensityCheckButton', 'statusbar', 'expander1', 'messageLabel' ] # grab all our widgets for w in self.widget_names: setattr(self, w, self.ui.get_object(w)) # HACK FOR READABILITY w/o glade change self.resultLabel = self.amt2Label self.resultLabel.set_use_markup(True) self.resultLabel.set_line_wrap(True) if unitModel: self.unitModel = unitModel else: self.unitModel = gourmet.GourmetRecipeManager.UnitModel(self.conv) #self.unit2Model = self.unitModel.filter_new() self.unit1ComboBox.set_model(self.unitModel) self.unit1ComboBox.set_wrap_width(3) self.unit2ComboBox.set_wrap_width(3) #self.unit2Model.set_visible_func(self.unit_filter) #self.unit2ComboBox.set_model(self.unit2Model) self.unit2ComboBox.set_model(self.unitModel) for combobox in [self.unit1ComboBox, self.unit2ComboBox]: cell = gtk.CellRendererText() combobox.pack_start(cell, True) combobox.add_attribute(cell, 'text', 1) setup_typeahead(combobox) #self.itemComboBox.append_text('None') ikeys = self.conv.density_table.keys() ikeys.sort() for itm in ikeys: self.itemComboBox.append_text(itm) if len(self.conv.density_table.keys()) > 8: self.itemComboBox.set_wrap_width(3) setup_typeahead(self.itemComboBox) if amt1: self.amt1Entry = self.conv.float_to_frac(amt1) self.ui.connect_signals({ 'amt1changed': self.changed, 'unit1changed': self.changed, 'unit2changed': self.changed, 'itemChanged': self.density_itm_changed, 'densitySpinChanged': self.density_spin_changed, 'densityChecked': self.density_toggled, 'close': self.close, }) self.last_amt1 = None self.last_amt2 = None self.last_unit1 = None self.last_unit2 = None if unit1 and self.conv.unit_dict.has_key[unit1]: u = self.conv.unit_dict[unit1] cb_set_active_text(self.unit1ComboBox, u) if amt1: self.amt1Entry.set_text("%s" % amt1) if item: cb_set_active_text(self.itemComboBox, item)
def __init__ (self, converter=convert.get_converter(), unitModel=None, amt1=None, unit1=None, item=None, okcb=None ): self.possible_conversions = None self.ui = gtk.Builder() self.ui.add_from_file(os.path.join(current_path,'converter.ui')) self.conv = converter self.changing_item = False self.okcb = okcb self.widget_names = ['window','amt1Entry', 'amt2Label', 'unit1ComboBox', 'unit2ComboBox', 'itemComboBox', 'densitySpinButton', 'useDensityCheckButton', 'statusbar','expander1','messageLabel'] # grab all our widgets for w in self.widget_names: setattr(self,w,self.ui.get_object(w)) # HACK FOR READABILITY w/o glade change self.resultLabel = self.amt2Label self.resultLabel.set_use_markup(True) self.resultLabel.set_line_wrap(True) if unitModel: self.unitModel=unitModel else: self.unitModel=gourmet.GourmetRecipeManager.UnitModel(self.conv) #self.unit2Model = self.unitModel.filter_new() self.unit1ComboBox.set_model(self.unitModel) self.unit1ComboBox.set_wrap_width(3) self.unit2ComboBox.set_wrap_width(3) #self.unit2Model.set_visible_func(self.unit_filter) #self.unit2ComboBox.set_model(self.unit2Model) self.unit2ComboBox.set_model(self.unitModel) for combobox in [self.unit1ComboBox, self.unit2ComboBox]: cell = gtk.CellRendererText() combobox.pack_start(cell, True) combobox.add_attribute(cell, 'text', 1) setup_typeahead(combobox) #self.itemComboBox.append_text('None') ikeys = self.conv.density_table.keys() ikeys.sort() for itm in ikeys: self.itemComboBox.append_text(itm) if len(self.conv.density_table.keys()) > 8: self.itemComboBox.set_wrap_width(3) setup_typeahead(self.itemComboBox) if amt1: self.amt1Entry=self.conv.float_to_frac(amt1) self.ui.connect_signals({ 'amt1changed':self.changed, 'unit1changed':self.changed, 'unit2changed':self.changed, 'itemChanged':self.density_itm_changed, 'densitySpinChanged':self.density_spin_changed, 'densityChecked':self.density_toggled, 'close':self.close, }) self.last_amt1 = None self.last_amt2 = None self.last_unit1 = None self.last_unit2 = None if unit1 and self.conv.unit_dict.has_key[unit1]: u = self.conv.unit_dict[unit1] cb_set_active_text(self.unit1ComboBox,u) if amt1: self.amt1Entry.set_text("%s"%amt1) if item: cb_set_active_text(self.itemComboBox,item)