本文整理汇总了Python中tryton.gui.window.view_form.screen.Screen.get_buttons方法的典型用法代码示例。如果您正苦于以下问题:Python Screen.get_buttons方法的具体用法?Python Screen.get_buttons怎么用?Python Screen.get_buttons使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tryton.gui.window.view_form.screen.Screen
的用法示例。
在下文中一共展示了Screen.get_buttons方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Form
# 需要导入模块: from tryton.gui.window.view_form.screen import Screen [as 别名]
# 或者: from tryton.gui.window.view_form.screen.Screen import get_buttons [as 别名]
#.........这里部分代码省略.........
action_type, toolbars[action_type], special_action)
tbutton.connect('toggled', self.action_popup)
self.tooltips.set_tip(tbutton, tooltip)
self.buttons[special_action] = tbutton
if action_type != 'action':
tbutton._can_be_sensitive = bool(
tbutton._menu.get_children())
else:
tbutton = gtk.SeparatorToolItem()
gtktoolbar.insert(tbutton, -1)
return gtktoolbar
def _create_popup_menu(self, widget, keyword, actions, special_action):
menu = gtk.Menu()
menu.connect('deactivate', self._popup_menu_hide, widget)
widget.connect('toggled', self._update_popup, menu, special_action)
for action in actions:
new_action = action.copy()
if special_action == 'print':
new_action['direct_print'] = True
elif special_action == 'email':
new_action['email_print'] = True
action_name = action['name']
if '_' not in action_name:
action_name = '_' + action_name
menuitem = gtk.MenuItem(action_name)
menuitem.set_use_underline(True)
menuitem.connect('activate', self._popup_menu_selected, widget,
new_action, keyword)
menu.add(menuitem)
return menu
def _popup_menu_selected(self, menuitem, togglebutton, action, keyword):
event = gtk.get_current_event()
allow_similar = False
if (event.state & gtk.gdk.CONTROL_MASK
or event.state & gtk.gdk.MOD1_MASK):
allow_similar = True
with Window(hide_current=True, allow_similar=allow_similar):
self._action(action, keyword)
togglebutton.props.active = False
def _popup_menu_hide(self, menuitem, togglebutton):
togglebutton.props.active = False
def _update_popup(self, tbutton, menu, keyword):
assert keyword in ['print','action','relate','email','open']
for item in menu.get_children():
if (getattr(item, '_update_action', False)
or isinstance(item, gtk.SeparatorMenuItem)):
menu.remove(item)
buttons = [button for button in self.screen.get_buttons()
if keyword in button.attrs.get('keywords', 'action').split(',')]
if buttons:
menu.add(gtk.SeparatorMenuItem())
for button in buttons:
menuitem = gtk.ImageMenuItem(button.attrs.get('icon'))
menuitem.set_label('_' + button.attrs.get('string', _('Unknown')))
menuitem.set_use_underline(True)
menuitem.connect('activate',
lambda m, attrs: self.screen.button(attrs), button.attrs)
menuitem._update_action = True
menu.add(menuitem)
if keyword == 'action':
menu.add(gtk.SeparatorMenuItem())
for plugin in plugins.MODULES:
for name, func in plugin.get_plugins(self.model):
menuitem = gtk.MenuItem('_' + name)
menuitem.set_use_underline(True)
menuitem.connect('activate', lambda m, func: func({
'model': self.model,
'ids': [r.id
for r in self.screen.selected_records],
'id': (self.screen.current_record.id
if self.screen.current_record else None),
}), func)
menuitem._update_action = True
menu.add(menuitem)
def set_cursor(self):
if self.screen:
self.screen.set_cursor(reset_view=False)
def attach_drag_data_received(self, widget, context, x, y, selection, info,
timestamp):
record = self.screen.current_record
if not record or record.id < 0:
return
win_attach = Attachment(record,
lambda: self.update_attachment_count(reload=True))
if info == 0:
for uri in selection.data.splitlines():
# Win32 cut&paste terminates the list with a NULL character
if not uri or uri == '\0':
continue
win_attach.add_uri(uri)