def _main_window_add_actions(self, button_box):
for action in self.config['main_window'].get('actions', []):
if action.get('type', 'button') == 'button':
widget = gtk.Button(label=action.get('label', 'OK'))
event = "clicked"
elif action['type'] == 'checkbox':
widget = gtk.CheckButton(label=action.get('label', '?'))
event = "toggled"
else:
raise NotImplementedError('We only have buttons atm.')
if action.get('position', 'left') in ('left', 'top'):
button_box.pack_start(widget, False, True)
elif action['position'] in ('right', 'bottom'):
button_box.pack_end(widget, False, True)
else:
raise NotImplementedError('Invalid position: %s'
% action['position'])
if action.get('op'):
def activate(o, a):
return lambda d: self._do(o, a)
widget.connect(event,
activate(action['op'], action.get('args', [])))
widget.set_sensitive(action.get('sensitive', True))
self.items[action['item']] = widget
评论列表
文章目录