gtkbase.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:gui-o-matic 作者: mailpile 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号