widget connections

svn: r6265
This commit is contained in:
Don Allingham 2006-04-04 22:42:38 +00:00
parent fd8ae5b10b
commit 3a80310d16
2 changed files with 38 additions and 5 deletions

View File

@ -122,6 +122,13 @@ class EditLdsOrd(EditSecondary):
for val in lds.temple_codes.keys(): for val in lds.temple_codes.keys():
temple_list.append((lds.temple_codes[val],val)) temple_list.append((lds.temple_codes[val],val))
self.type_menu = MonitoredStrMenu(
self.top.get_widget('temple'),
self.obj.set_temple,
self.obj.get_temple,
temple_list,
self.db.readonly)
def _create_tabbed_pages(self): def _create_tabbed_pages(self):
notebook = gtk.Notebook() notebook = gtk.Notebook()
self.srcref_list = self._add_tab( self.srcref_list = self._add_tab(

View File

@ -362,15 +362,41 @@ class MonitoredMenu:
self.obj.set_active(value) self.obj.set_active(value)
def on_change(self, obj): def on_change(self, obj):
print obj
print obj.get_active_iter()
print self.model.get_value(obj.get_active_iter(),1)
self.set_val(self.model.get_value(obj.get_active_iter(),1)) self.set_val(self.model.get_value(obj.get_active_iter(),1))
def force(self,value): class MonitoredStrMenu:
self.obj.set_active(self.data.index(value))
def __init__(self,obj,set_val,get_val,mapping,readonly=False):
self.set_val = set_val
self.get_val = get_val
self.obj = obj
self.model = gtk.ListStore(str,int)
self.model.append(row=['',0])
index = 0
self.data = ['']
default = get_val()
active = 0
for t,v in mapping:
self.model.append(row=[t,index])
self.data.append(v)
if v == default:
active = index
index += 1
self.obj.set_model(self.model)
self.obj.set_active(index)
self.obj.connect('changed',self.on_change)
self.obj.set_sensitive(not readonly)
def on_change(self, obj): def on_change(self, obj):
value = self.data[self.model.get_value(obj.get_active_iter(),1)] self.set_val(self.data[obj.get_active()])
self.set_val(value)
class MonitoredDate: class MonitoredDate:
def __init__(self,field,button,value,window, readonly=False): def __init__(self,field,button,value,window, readonly=False):