New feature to allow added rules to define their own GUI elements

This commit is contained in:
prculley 2018-12-02 13:53:08 -06:00 committed by Nick Hall
parent eb36980715
commit 3ba2253ac0
2 changed files with 12 additions and 3 deletions

View File

@ -141,7 +141,9 @@ class Rule:
def display_values(self):
"""Return the labels and values of this rule."""
l_v = ( '%s="%s"' % (_(self.labels[ix]), self.list[ix])
l_v = ('%s="%s"' % (_(self.labels[ix][0] if
isinstance(self.labels[ix], tuple) else
self.labels[ix]), self.list[ix])
for ix in range(len(self.list)) if self.list[ix])
return ';'.join(l_v)

View File

@ -501,6 +501,10 @@ class EditRule(ManagedWindow):
grid.set_row_spacing(6)
grid.show()
for v in arglist:
if isinstance(v, tuple):
# allows filter to create its own GUI element
l = Gtk.Label(label=v[0], halign=Gtk.Align.END)
else:
l = Gtk.Label(label=v, halign=Gtk.Align.END)
l.show()
if v == _('Place:'):
@ -585,6 +589,9 @@ class EditRule(ManagedWindow):
elif v == _('Units:'):
t = MyList([0, 1, 2],
[_('kilometers'), _('miles'), _('degrees')])
elif isinstance(v, tuple):
# allow filter to create its own GUI element
t = v[1](self.db)
else:
t = MyEntry()
t.set_hexpand(True)