本文整理汇总了Python中tryton.gui.window.view_form.screen.Screen.sel_ids_get方法的典型用法代码示例。如果您正苦于以下问题:Python Screen.sel_ids_get方法的具体用法?Python Screen.sel_ids_get怎么用?Python Screen.sel_ids_get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tryton.gui.window.view_form.screen.Screen
的用法示例。
在下文中一共展示了Screen.sel_ids_get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: WinSearch
# 需要导入模块: from tryton.gui.window.view_form.screen import Screen [as 别名]
# 或者: from tryton.gui.window.view_form.screen.Screen import sel_ids_get [as 别名]
class WinSearch(NoModal):
def __init__(self, model, callback, sel_multi=True, ids=None, context=None,
domain=None, view_ids=None, views_preload=None):
NoModal.__init__(self)
if views_preload is None:
views_preload = {}
self.domain = domain or []
self.context = context or {}
self.sel_multi = sel_multi
self.callback = callback
self.win = gtk.Dialog(_('Search'), self.parent,
gtk.DIALOG_DESTROY_WITH_PARENT)
self.win.set_icon(TRYTON_ICON)
self.win.set_has_separator(True)
self.win.set_default_response(gtk.RESPONSE_APPLY)
self.win.connect('response', self.response)
self.accel_group = gtk.AccelGroup()
self.win.add_accel_group(self.accel_group)
self.but_cancel = self.win.add_button(gtk.STOCK_CANCEL,
gtk.RESPONSE_CANCEL)
self.but_find = self.win.add_button(gtk.STOCK_FIND, gtk.RESPONSE_APPLY)
self.but_ok = self.win.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
self.but_ok.add_accelerator('clicked', self.accel_group,
gtk.keysyms.Return, gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
self.but_new = self.win.add_button(gtk.STOCK_NEW, gtk.RESPONSE_ACCEPT)
hbox = gtk.HBox()
hbox.show()
self.win.vbox.pack_start(hbox, expand=False, fill=True)
self.win.vbox.pack_start(gtk.HSeparator(), expand=False, fill=True)
scrollwindow = gtk.ScrolledWindow()
scrollwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
self.win.vbox.pack_start(scrollwindow, expand=True, fill=True)
self.screen = Screen(model, domain=domain, mode=['tree'],
context=context, view_ids=view_ids, views_preload=views_preload,
row_activate=self.sig_activate)
self.view = self.screen.current_view
self.view.unset_editable()
sel = self.view.widget_tree.get_selection()
if not sel_multi:
sel.set_mode(gtk.SELECTION_SINGLE)
else:
sel.set_mode(gtk.SELECTION_MULTIPLE)
viewport = gtk.Viewport()
viewport.set_shadow_type(gtk.SHADOW_NONE)
viewport.add(self.screen.widget)
self.screen.widget.show()
viewport.show()
scrollwindow.add(viewport)
scrollwindow.show()
self.model_name = model
if ids:
self.screen.load(ids)
self.win.set_size_request(700, 500)
self.register()
sensible_allocation = self.sensible_widget.get_allocation()
self.win.set_default_size(int(sensible_allocation.width * 0.9),
int(sensible_allocation.height * 0.9))
self.win.show()
common.center_window(self.win, self.parent, self.sensible_widget)
def sig_activate(self, *args):
self.view.widget_tree.emit_stop_by_name('row_activated')
self.win.response(gtk.RESPONSE_OK)
return True
def destroy(self):
self.screen.destroy()
self.win.destroy()
NoModal.destroy(self)
def show(self):
self.win.show()
def hide(self):
self.win.hide()
def response(self, win, response_id):
res = None
if response_id == gtk.RESPONSE_OK:
res = self.screen.sel_ids_get()
elif response_id == gtk.RESPONSE_APPLY:
if not self.screen.search_filter():
res = self.screen.sel_ids_get()
else:
return
elif response_id == gtk.RESPONSE_ACCEPT:
screen = Screen(self.model_name, domain=self.domain,
context=self.context, mode=['form'])
#.........这里部分代码省略.........
示例2: Form
# 需要导入模块: from tryton.gui.window.view_form.screen import Screen [as 别名]
# 或者: from tryton.gui.window.view_form.screen.Screen import sel_ids_get [as 别名]
#.........这里部分代码省略.........
def get_toolbars(self):
try:
return RPCExecute('model', self.model, 'view_toolbar_get',
context=self.context)
except RPCException:
return {}
def widget_get(self):
return self.screen.widget
def __eq__(self, value):
if not value:
return False
if not isinstance(value, Form):
return False
return (self.model == value.model
and self.res_id == value.res_id
and self.domain == value.domain
and self.mode == value.mode
and self.view_ids == value.view_ids
and self.context == value.context
and self.name == value.name
and self.screen.limit == value.screen.limit
and self.auto_refresh == value.auto_refresh
and self.screen.search_value == value.screen.search_value)
def destroy(self):
self.screen.destroy()
self.screen = None
self.widget = None
#self.scrolledwindow.destroy()
#self.scrolledwindow = None
def sel_ids_get(self):
return self.screen.sel_ids_get()
def ids_get(self):
return self.screen.ids_get()
def id_get(self):
return self.screen.id_get()
def sig_attach(self, widget=None):
record_id = self.id_get()
if record_id is False or record_id < 0:
return
Attachment(self.model, record_id,
lambda: self.update_attachment_count(reload=True))
def update_attachment_count(self, reload=False):
record = self.screen.current_record
if record:
attachment_count = record.get_attachment_count(reload=reload)
else:
attachment_count = 0
self._attachment_count(None, attachment_count)
def _attachment_count(self, widget, signal_data):
label = _('Attachment(%d)') % signal_data
self.buttons['attach'].set_label(label)
if signal_data:
self.buttons['attach'].set_stock_id('tryton-attachment-hi')
else:
self.buttons['attach'].set_stock_id('tryton-attachment')
record_id = self.id_get()
self.buttons['attach'].props.sensitive = bool(