本文整理匯總了Python中tryton.gui.window.view_form.screen.Screen.switch_view方法的典型用法代碼示例。如果您正苦於以下問題:Python Screen.switch_view方法的具體用法?Python Screen.switch_view怎麽用?Python Screen.switch_view使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tryton.gui.window.view_form.screen.Screen
的用法示例。
在下文中一共展示了Screen.switch_view方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: One2Many
# 需要導入模塊: from tryton.gui.window.view_form.screen import Screen [as 別名]
# 或者: from tryton.gui.window.view_form.screen.Screen import switch_view [as 別名]
#.........這裏部分代碼省略.........
self.but_undel.add(img_undel)
self.but_undel.set_relief(gtk.RELIEF_NONE)
hbox.pack_start(self.but_undel, expand=False, fill=False)
hbox.pack_start(gtk.VSeparator(), expand=False, fill=True)
self.but_pre = gtk.Button()
tooltips.set_tip(self.but_pre, _("Previous"))
self.but_pre.connect("clicked", self._sig_previous)
img_pre = gtk.Image()
img_pre.set_from_stock("tryton-go-previous", gtk.ICON_SIZE_SMALL_TOOLBAR)
img_pre.set_alignment(0.5, 0.5)
self.but_pre.add(img_pre)
self.but_pre.set_relief(gtk.RELIEF_NONE)
hbox.pack_start(self.but_pre, expand=False, fill=False)
self.label = gtk.Label("(0,0)")
hbox.pack_start(self.label, expand=False, fill=False)
self.but_next = gtk.Button()
tooltips.set_tip(self.but_next, _("Next"))
self.but_next.connect("clicked", self._sig_next)
img_next = gtk.Image()
img_next.set_from_stock("tryton-go-next", gtk.ICON_SIZE_SMALL_TOOLBAR)
img_next.set_alignment(0.5, 0.5)
self.but_next.add(img_next)
self.but_next.set_relief(gtk.RELIEF_NONE)
hbox.pack_start(self.but_next, expand=False, fill=False)
hbox.pack_start(gtk.VSeparator(), expand=False, fill=True)
but_switch = gtk.Button()
tooltips.set_tip(but_switch, _("Switch"))
but_switch.connect("clicked", self.switch_view)
img_switch = gtk.Image()
img_switch.set_from_stock("tryton-fullscreen", gtk.ICON_SIZE_SMALL_TOOLBAR)
img_switch.set_alignment(0.5, 0.5)
but_switch.add(img_switch)
but_switch.set_relief(gtk.RELIEF_NONE)
hbox.pack_start(but_switch, expand=False, fill=False)
if attrs.get("add_remove"):
hbox.set_focus_chain([self.wid_text])
else:
hbox.set_focus_chain([])
tooltips.enable()
frame = gtk.Frame()
frame.add(hbox)
if attrs.get("expand_toolbar"):
frame.set_shadow_type(gtk.SHADOW_NONE)
else:
frame.set_shadow_type(gtk.SHADOW_OUT)
vbox.pack_start(frame, expand=False, fill=True)
self.screen = Screen(
attrs["relation"],
mode=attrs.get("mode", "tree,form").split(","),
view_ids=attrs.get("view_ids", "").split(","),
views_preload=attrs.get("views", {}),
row_activate=self._on_activate,
readonly=self.attrs.get("readonly", False),
exclude_field=attrs.get("relation_field", None),
)
示例2: Form
# 需要導入模塊: from tryton.gui.window.view_form.screen import Screen [as 別名]
# 或者: from tryton.gui.window.view_form.screen.Screen import switch_view [as 別名]
#.........這裏部分代碼省略.........
def sig_note(self, widget=None):
record = self.screen.current_record
if not record or record.id < 0:
return
Note(record,
lambda: self.update_unread_note(reload=True))
def update_unread_note(self, reload=False):
record = self.screen.current_record
if record:
unread = record.get_unread_note(reload=reload)
else:
unread = 0
self._unread_note(None, unread)
def _unread_note(self, widget, signal_data):
label = _('Note(%d)') % signal_data
self.buttons['note'].set_label(label)
if signal_data:
self.buttons['note'].set_stock_id('tryton-note-hi')
else:
self.buttons['note'].set_stock_id('tryton-note')
record = self.screen.current_record
if not record or record.id < 0:
sensitive = False
else:
sensitive = True
self.buttons['note'].props.sensitive = sensitive
def sig_switch(self, widget=None):
if not self.modified_save():
return
self.screen.switch_view()
def sig_logs(self, widget=None):
current_record = self.screen.current_record
if not current_record or current_record.id < 0:
self.message_info(
_('You have to select one record.'), gtk.MESSAGE_INFO)
return False
fields = [
('id', _('ID:')),
('create_uid.rec_name', _('Creation User:')),
('create_date', _('Creation Date:')),
('write_uid.rec_name', _('Latest Modification by:')),
('write_date', _('Latest Modification Date:')),
]
try:
res = RPCExecute('model', self.model, 'read', [current_record.id],
[x[0] for x in fields], context=self.screen.context)
except RPCException:
return
date_format = self.screen.context.get('date_format', '%x')
datetime_format = date_format + ' %X.%f'
message_str = ''
for line in res:
for (key, val) in fields:
value = str(line.get(key, False) or '/')
if line.get(key, False) \
and key in ('create_date', 'write_date'):
date = timezoned_date(line[key])
value = common.datetime_strftime(date, datetime_format)
message_str += val + ' ' + value + '\n'
示例3: Preference
# 需要導入模塊: from tryton.gui.window.view_form.screen import Screen [as 別名]
# 或者: from tryton.gui.window.view_form.screen.Screen import switch_view [as 別名]
class Preference(NoModal):
"Preference window"
def __init__(self, user, callback):
NoModal.__init__(self)
self.callback = callback
self.win = gtk.Dialog(_('Preferences'), self.parent,
gtk.DIALOG_DESTROY_WITH_PARENT)
self.win.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
self.win.set_has_separator(False)
self.win.set_icon(TRYTON_ICON)
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_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.win.set_default_response(gtk.RESPONSE_OK)
self.win.connect('response', self.response)
try:
view = RPCExecute('model', 'res.user',
'get_preferences_fields_view')
except RPCException:
self.win.destroy()
self.win = None
return
title = gtk.Label(_('Edit User Preferences'))
title.show()
self.win.vbox.pack_start(title, expand=False, fill=True)
self.screen = Screen('res.user', mode=[])
# Reset readonly set automaticly by MODELACCESS
self.screen.readonly = False
self.screen.group.readonly = False
self.screen.group.skip_model_access = True
self.screen.add_view(view)
self.screen.switch_view()
self.screen.new(default=False)
try:
preferences = RPCExecute('model', 'res.user', 'get_preferences',
False)
except RPCException:
self.win.destroy()
self.win = None
return
self.screen.current_record.set(preferences)
self.screen.current_record.id = rpc._USER
self.screen.current_record.validate(softvalidation=True)
self.screen.display(set_cursor=True)
self.screen.widget.show()
self.win.vbox.pack_start(self.screen.widget)
self.win.set_title(_('Preference'))
width, height = self.parent.get_size()
self.win.set_default_size(int(width * 0.9), int(height * 0.9))
self.register()
self.win.show()
def response(self, win, response_id):
if response_id == gtk.RESPONSE_OK:
if self.screen.current_record.validate():
vals = copy.copy(self.screen.get())
if 'password' in vals:
password = common.ask(_('Current Password:'),
visibility=False)
if not password:
return
else:
password = False
try:
RPCExecute('model', 'res.user', 'set_preferences',
vals, password)
except RPCException:
return
self.parent.present()
self.destroy()
self.callback()
def destroy(self):
self.screen.destroy()
self.win.destroy()
NoModal.destroy(self)
示例4: One2Many
# 需要導入模塊: from tryton.gui.window.view_form.screen import Screen [as 別名]
# 或者: from tryton.gui.window.view_form.screen.Screen import switch_view [as 別名]
#.........這裏部分代碼省略.........
self.but_undel.set_relief(gtk.RELIEF_NONE)
hbox.pack_start(self.but_undel, expand=False, fill=False)
hbox.pack_start(gtk.VSeparator(), expand=False, fill=True)
self.but_pre = gtk.Button()
tooltips.set_tip(self.but_pre, _('Previous'))
self.but_pre.connect('clicked', self._sig_previous)
img_pre = gtk.Image()
img_pre.set_from_stock('tryton-go-previous',
gtk.ICON_SIZE_SMALL_TOOLBAR)
img_pre.set_alignment(0.5, 0.5)
self.but_pre.add(img_pre)
self.but_pre.set_relief(gtk.RELIEF_NONE)
hbox.pack_start(self.but_pre, expand=False, fill=False)
self.label = gtk.Label('(0,0)')
hbox.pack_start(self.label, expand=False, fill=False)
self.but_next = gtk.Button()
tooltips.set_tip(self.but_next, _('Next'))
self.but_next.connect('clicked', self._sig_next)
img_next = gtk.Image()
img_next.set_from_stock('tryton-go-next', gtk.ICON_SIZE_SMALL_TOOLBAR)
img_next.set_alignment(0.5, 0.5)
self.but_next.add(img_next)
self.but_next.set_relief(gtk.RELIEF_NONE)
hbox.pack_start(self.but_next, expand=False, fill=False)
hbox.pack_start(gtk.VSeparator(), expand=False, fill=True)
but_switch = gtk.Button()
tooltips.set_tip(but_switch, _('Switch'))
but_switch.connect('clicked', self.switch_view)
img_switch = gtk.Image()
img_switch.set_from_stock('tryton-fullscreen',
gtk.ICON_SIZE_SMALL_TOOLBAR)
img_switch.set_alignment(0.5, 0.5)
but_switch.add(img_switch)
but_switch.set_relief(gtk.RELIEF_NONE)
hbox.pack_start(but_switch, expand=False, fill=False)
if attrs.get('add_remove'):
hbox.set_focus_chain([self.wid_text])
else:
hbox.set_focus_chain([])
tooltips.enable()
frame = gtk.Frame()
frame.add(hbox)
frame.set_shadow_type(gtk.SHADOW_OUT)
self.widget.pack_start(frame, expand=False, fill=True)
self.screen = Screen(attrs['relation'],
mode=attrs.get('mode', 'tree,form').split(','),
view_ids=attrs.get('view_ids', '').split(','),
views_preload=attrs.get('views', {}),
row_activate=self._on_activate,
exclude_field=attrs.get('relation_field', None))
self.screen.signal_connect(self, 'record-message', self._sig_label)
self.widget.pack_start(self.screen.widget, expand=True, fill=True)
self.screen.widget.connect('key_press_event', self.on_keypress)
if self.attrs.get('add_remove'):
示例5: One2Many
# 需要導入模塊: from tryton.gui.window.view_form.screen import Screen [as 別名]
# 或者: from tryton.gui.window.view_form.screen.Screen import switch_view [as 別名]
#.........這裏部分代碼省略.........
self.but_undel.set_relief(gtk.RELIEF_NONE)
hbox.pack_start(self.but_undel, expand=False, fill=False)
hbox.pack_start(gtk.VSeparator(), expand=False, fill=True)
self.but_pre = gtk.Button()
tooltips.set_tip(self.but_pre, _('Previous'))
self.but_pre.connect('clicked', self._sig_previous)
img_pre = gtk.Image()
img_pre.set_from_stock('tryton-go-previous',
gtk.ICON_SIZE_SMALL_TOOLBAR)
img_pre.set_alignment(0.5, 0.5)
self.but_pre.add(img_pre)
self.but_pre.set_relief(gtk.RELIEF_NONE)
hbox.pack_start(self.but_pre, expand=False, fill=False)
self.label = gtk.Label('(0,0)')
hbox.pack_start(self.label, expand=False, fill=False)
self.but_next = gtk.Button()
tooltips.set_tip(self.but_next, _('Next'))
self.but_next.connect('clicked', self._sig_next)
img_next = gtk.Image()
img_next.set_from_stock('tryton-go-next', gtk.ICON_SIZE_SMALL_TOOLBAR)
img_next.set_alignment(0.5, 0.5)
self.but_next.add(img_next)
self.but_next.set_relief(gtk.RELIEF_NONE)
hbox.pack_start(self.but_next, expand=False, fill=False)
hbox.pack_start(gtk.VSeparator(), expand=False, fill=True)
but_switch = gtk.Button()
tooltips.set_tip(but_switch, _('Switch'))
but_switch.connect('clicked', self.switch_view)
img_switch = gtk.Image()
img_switch.set_from_stock('tryton-fullscreen',
gtk.ICON_SIZE_SMALL_TOOLBAR)
img_switch.set_alignment(0.5, 0.5)
but_switch.add(img_switch)
but_switch.set_relief(gtk.RELIEF_NONE)
hbox.pack_start(but_switch, expand=False, fill=False)
if attrs.get('add_remove'):
hbox.set_focus_chain([self.wid_text])
else:
hbox.set_focus_chain([])
tooltips.enable()
frame = gtk.Frame()
frame.add(hbox)
frame.set_shadow_type(gtk.SHADOW_OUT)
vbox.pack_start(frame, expand=False, fill=True)
self.screen = Screen(attrs['relation'],
mode=attrs.get('mode', 'tree,form').split(','),
view_ids=attrs.get('view_ids', '').split(','),
views_preload=attrs.get('views', {}),
row_activate=self._on_activate,
readonly=self.attrs.get('readonly', False),
exclude_field=attrs.get('relation_field', None))
self.screen.pre_validate = bool(int(attrs.get('pre_validate', 0)))
self.screen.signal_connect(self, 'record-message', self._sig_label)
vbox.pack_start(self.screen.widget, expand=True, fill=True)
示例6: Form
# 需要導入模塊: from tryton.gui.window.view_form.screen import Screen [as 別名]
# 或者: from tryton.gui.window.view_form.screen.Screen import switch_view [as 別名]
#.........這裏部分代碼省略.........
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(
record_id >= 0 and record_id is not False)
def sig_switch(self, widget=None):
if not self.modified_save():
return
self.screen.switch_view()
def sig_logs(self, widget=None):
obj_id = self.id_get()
if obj_id < 0 or obj_id is False:
self.message_info(_('You have to select one record!'))
return False
fields = [
('id', _('ID:')),
('create_uid.rec_name', _('Creation User:')),
('create_date', _('Creation Date:')),
('write_uid.rec_name', _('Latest Modification by:')),
('write_date', _('Latest Modification Date:')),
]
try:
res = RPCExecute('model', self.model, 'read', [obj_id],
[x[0] for x in fields], context=self.context)
except RPCException:
return
message_str = ''
for line in res:
for (key, val) in fields:
value = str(line.get(key, False) or '/')
if line.get(key, False) \
and key in ('create_date', 'write_date'):
display_format = date_format() + ' %H:%M:%S'
date = timezoned_date(line[key])
value = common.datetime_strftime(date, display_format)
message_str += val + ' ' + value + '\n'
message_str += _('Model:') + ' ' + self.model
message(message_str)