• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python screen.Screen类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tryton.gui.window.view_form.screen.Screen的典型用法代码示例。如果您正苦于以下问题:Python Screen类的具体用法?Python Screen怎么用?Python Screen使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Screen类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _sig_edit

    def _sig_edit(self):
        if not self.screen.current_record:
            return
        # Create a new screen that is not linked to the parent otherwise on the
        # save of the record will trigger the save of the parent
        domain = self.field.domain_get(self.record)
        add_remove = self.record.expr_eval(self.attrs.get('add_remove'))
        if add_remove:
            domain = [domain, add_remove]
        context = self.field.context_get(self.record)

        screen = Screen(self.attrs['relation'], domain=domain,
            view_ids=self.attrs.get('view_ids', '').split(','),
            mode=['form'], views_preload=self.attrs.get('views', {}),
            readonly=self.attrs.get('readonly', False),
            context=context)
        screen.load([self.screen.current_record.id])

        def callback(result):
            if result:
                screen.current_record.save()
                # Force a reload on next display
                self.screen.current_record.cancel()
                # Force a display to clear the CellCache
                self.screen.display()
        WinForm(screen, callback)
开发者ID:coopengo,项目名称:tryton,代码行数:26,代码来源:many2many.py


示例2: __init__

 def __init__(self, record, callback=None):
     self.resource = '%s,%s' % (record.model_name, record.id)
     self.note_callback = callback
     context = record.context_get()
     context['resource'] = self.resource
     screen = Screen('ir.note', domain=[
             ('resource', '=', self.resource),
             ], mode=['tree', 'form'], context=context,
         exclude_field='resource')
     super(Note, self).__init__(screen, self.callback, view_type='tree')
     screen.search_filter()
开发者ID:coopengo,项目名称:tryton,代码行数:11,代码来源:note.py


示例3: __init__

 def __init__(self, model_name, record_id, callback=None):
     self.resource = '%s,%s' % (model_name, record_id)
     self.attachment_callback = callback
     screen = Screen('ir.attachment', domain=[
         ('resource', '=', self.resource),
         ], mode=['tree', 'form'], context={
             'resource': self.resource,
         }, exclude_field='resource')
     screen.search_filter()
     screen.parent = True
     super(Attachment, self).__init__(screen, self.callback,
         view_type='tree')
开发者ID:mediafactory,项目名称:tryton_client_desktop,代码行数:12,代码来源:attachment.py


示例4: open_remote

    def open_remote(self, record, create=True, changed=False, text=None,
            callback=None):
        field = record.group.fields[self.field_name]
        relation = field.attrs['relation']

        domain = field.domain_get(record)
        context = field.context_get(record)
        if create:
            obj_id = None
        elif not changed:
            obj_id = field.get(record)
        else:
            if text:
                dom = [('rec_name', 'ilike', '%' + text + '%'), domain]
            else:
                dom = domain
            try:
                ids = RPCExecute('model', relation, 'search', dom, 0, None,
                    None, context=context)
            except RPCException:
                field.set_client(record, False)
                if callback:
                    callback()
                return
            if len(ids) == 1:
                field.set_client(record, ids[0])
                if callback:
                    callback()
                return
            self.search_remote(record, relation, ids, domain=domain,
                context=context, callback=callback)
            return
        screen = Screen(relation, domain=domain, context=context,
            mode=['form'])

        def open_callback(result):
            if result and screen.save_current():
                value = (screen.current_record.id,
                    screen.current_record.rec_name())
                field.set_client(record, value, force_change=True)
            elif result:
                screen.display()
                return WinForm(screen, open_callback)
            if callback:
                callback()
        if obj_id:
            screen.load([obj_id])
            WinForm(screen, open_callback)
        else:
            WinForm(screen, open_callback, new=True)
开发者ID:mediafactory,项目名称:tryton_client_desktop,代码行数:50,代码来源:parser.py


示例5: __init__

    def __init__(self, view, attrs):
        super(Many2ManySelection, self).__init__(view, attrs)

        self.widget = gtk.VBox(homogeneous=False, spacing=5)

        hbox = gtk.HBox(homogeneous=False, spacing=0)
        hbox.set_border_width(2)

        label = gtk.Label(attrs.get("string", ""))
        label.set_alignment(0.0, 0.5)
        hbox.pack_start(label, expand=True, fill=True)

        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"],
            view_ids=attrs.get("view_ids", "").split(","),
            mode=["tree"],
            views_preload=attrs.get("views", {}),
        )
        self.screen.new_group()
        self.treeview = self.screen.current_view.treeview
        self.treeview.get_selection().connect("changed", self.changed)
        self.treeview.connect("focus-out-event", lambda *a: self._focus_out())

        self.treeview.connect("button-press-event", self.button_press_event)
        self.treeview.connect("key-press-event", self.key_press_event)

        self.widget.pack_start(self.screen.widget, expand=True, fill=True)

        self.nullable_widget = False
        self.init_selection()
开发者ID:coopengo,项目名称:tryton,代码行数:35,代码来源:many2many_selection.py


示例6: __init__

    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.95), int(height * 0.95))

        self.register()
        self.win.show()
开发者ID:coopengo,项目名称:tryton,代码行数:59,代码来源:preference.py


示例7: __init__

    def __init__(self, model, res_id=False, domain=None, mode=None,
            view_ids=None, context=None, name=False, limit=None,
            auto_refresh=False, search_value=None):
        super(Form, self).__init__()

        if not mode:
            mode = ['tree', 'form']
        if domain is None:
            domain = []
        if view_ids is None:
            view_ids = []
        if context is None:
            context = {}

        self.model = model
        self.res_id = res_id
        self.domain = domain
        self.mode = mode
        self.context = context
        self.auto_refresh = auto_refresh
        self.view_ids = view_ids
        self.dialogs = []

        self.screen = Screen(self.model, mode=mode, context=self.context,
            view_ids=view_ids, domain=domain, limit=limit,
            readonly=bool(auto_refresh), search_value=search_value)
        self.screen.widget.show()

        if not name:
            self.name = self.screen.current_view.title
        else:
            self.name = name

        self.create_tabcontent()
        self.screen.signal_connect(self, 'record-message',
            self._record_message)
        self.screen.signal_connect(self, 'record-modified',
            lambda *a: gobject.idle_add(self._record_modified, *a))
        self.screen.signal_connect(self, 'record-saved', self._record_saved)
        self.screen.signal_connect(self, 'attachment-count',
                self._attachment_count)

        if res_id not in (None, False):
            if isinstance(res_id, (int, long)):
                res_id = [res_id]
            self.screen.load(res_id)
        else:
            if self.screen.current_view.view_type == 'form':
                self.sig_new(None, autosave=False)
            if self.screen.current_view.view_type \
                    in ('tree', 'graph', 'calendar'):
                self.screen.search_filter()

        if auto_refresh and int(auto_refresh):
            gobject.timeout_add(int(auto_refresh) * 1000, self.sig_reload)
开发者ID:mediafactory,项目名称:tryton_client_desktop,代码行数:55,代码来源:form.py


示例8: open_remote

    def open_remote(self, record, create=True, changed=False, text=None,
            callback=None):
        group = record.value[self.attrs['name']]
        field = record.group.fields[self.attrs['name']]
        relation = field.attrs['relation']
        context = field.context_get(record)

        access = common.MODELACCESS[relation]
        if not access['read']:
            return

        screen = Screen(relation, mode=['tree', 'form'],
            exclude_field=field.attrs.get('relation_field'))
        screen.pre_validate = bool(int(self.attrs.get('pre_validate', 0)))
        screen.group = group

        def open_callback(result):
            if callback:
                callback()
        WinForm(screen, open_callback, view_type='tree', context=context)
开发者ID:kret0s,项目名称:gnuhealth-live,代码行数:20,代码来源:widget.py


示例9: click_and_relate

 def click_and_relate(self, action, value, path):
     data = {}
     context = {}
     act = action.copy()
     if not(value):
         message(_('You must select a record to use the relation!'))
         return False
     from tryton.gui.window.view_form.screen import Screen
     screen = Screen(self.screen.group.fields[
         path[1].name].attrs['relation'])
     screen.load([value])
     encoder = PYSONEncoder()
     act['domain'] = encoder.encode(screen.current_record.expr_eval(
         act.get('domain', []), check_load=False))
     act['context'] = encoder.encode(screen.current_record.expr_eval(
         act.get('context', {}), check_load=False))
     data['model'] = self.screen.model_name
     data['id'] = value
     data['ids'] = [value]
     return Action._exec_action(act, data, context)
开发者ID:mediafactory,项目名称:tryton_client_desktop,代码行数:20,代码来源:list.py


示例10: __init__

    def __init__(self, user):
        self.parent = common.get_toplevel_window()
        self.win = gtk.Dialog(_("Preferences"), self.parent, gtk.DIALOG_MODAL | 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)

        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=[])
        self.screen.add_view(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.validate(softvalidation=True)
        self.screen.screen_container.set(self.screen.current_view.widget)
        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.win.show()
开发者ID:mediafactory,项目名称:tryton_client_desktop,代码行数:51,代码来源:preference.py


示例11: open_remote

    def open_remote(self, record, create=True, changed=False, text=None,
            callback=None):
        field = record.group.fields[self.attrs['name']]
        relation = field.attrs['relation']

        access = common.MODELACCESS[relation]
        if (create
                and not (self.attrs.get('create', True) and access['create'])):
            return
        elif not access['read']:
            return

        domain = field.domain_get(record)
        context = field.context_get(record)
        if create:
            obj_id = None
        elif not changed:
            obj_id = field.get(record)
        else:
            self.search_remote(record, relation, text, domain=domain,
                context=context, callback=callback).show()
            return
        screen = Screen(relation, domain=domain, context=context,
            mode=['form'], view_ids=self.attrs.get('view_ids', '').split(','),
            exclude_field=field.attrs.get('relation_field'))

        def open_callback(result):
            if result:
                value = (screen.current_record.id,
                    screen.current_record.rec_name())
                field.set_client(record, value, force_change=True)
            if callback:
                callback()
        if obj_id:
            screen.load([obj_id])
            WinForm(screen, open_callback, save_current=True)
        else:
            WinForm(screen, open_callback, new=True, save_current=True)
开发者ID:coopengo,项目名称:tryton,代码行数:38,代码来源:widget.py


示例12: __init__


#.........这里部分代码省略.........
        hbox.pack_start(self.but_open, expand=False, fill=False)

        self.but_del = gtk.Button()
        tooltips.set_tip(self.but_del, _("Delete selected record <Del>"))
        self.but_del.connect("clicked", self._sig_remove, False)
        img_del = gtk.Image()
        img_del.set_from_stock("tryton-delete", gtk.ICON_SIZE_SMALL_TOOLBAR)
        img_del.set_alignment(0.5, 0.5)
        self.but_del.add(img_del)
        self.but_del.set_relief(gtk.RELIEF_NONE)
        hbox.pack_start(self.but_del, expand=False, fill=False)

        self.but_undel = gtk.Button()
        tooltips.set_tip(self.but_undel, _("Undelete selected record <Ins>"))
        self.but_undel.connect("clicked", self._sig_undelete)
        img_undel = gtk.Image()
        img_undel.set_from_stock("tryton-undo", gtk.ICON_SIZE_SMALL_TOOLBAR)
        img_undel.set_alignment(0.5, 0.5)
        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),
        )
        self.screen.pre_validate = bool(int(attrs.get("pre_validate", 0)))
        self.screen.signal_connect(self, "record-message", self._sig_label)
        if self.attrs.get("group"):
            self.screen.signal_connect(
                self,
                "current-record-changed",
                lambda screen, _: gobject.idle_add(self.group_sync, screen, screen.current_record),
            )

        vbox.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"):
            self.wid_text.connect("key_press_event", self.on_keypress)

        but_switch.props.sensitive = self.screen.number_of_views > 1
开发者ID:coopengo,项目名称:tryton,代码行数:101,代码来源:one2many.py


示例13: One2Many


#.........这里部分代码省略.........
        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),
        )
        self.screen.pre_validate = bool(int(attrs.get("pre_validate", 0)))
        self.screen.signal_connect(self, "record-message", self._sig_label)
        if self.attrs.get("group"):
            self.screen.signal_connect(
                self,
                "current-record-changed",
                lambda screen, _: gobject.idle_add(self.group_sync, screen, screen.current_record),
            )

        vbox.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"):
            self.wid_text.connect("key_press_event", self.on_keypress)

        but_switch.props.sensitive = self.screen.number_of_views > 1

    def _color_widget(self):
        if hasattr(self.screen.current_view, "treeview"):
            return self.screen.current_view.treeview
        return super(One2Many, self)._color_widget()

    def on_keypress(self, widget, event):
        if (event.keyval == gtk.keysyms.F3) and self.but_new.get_property("sensitive"):
开发者ID:coopengo,项目名称:tryton,代码行数:67,代码来源:one2many.py


示例14: __init__

    def __init__(self, model, callback, sel_multi=True, context=None,
            domain=None, view_ids=None, views_preload=None, new=True):
        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)
        if new and common.MODELACCESS[model]['create']:
            self.but_new = self.win.add_button(gtk.STOCK_NEW,
                gtk.RESPONSE_ACCEPT)
            self.but_new.set_accel_path('<tryton>/Form/New', self.accel_group)

        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)

        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()
        # Prevent to set tree_state
        self.screen.tree_states_done.add(id(self.view))
        sel = self.view.treeview.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

        self.win.set_default_size(700, 500)

        self.register()
        sensible_allocation = self.sensible_widget.get_allocation()
        self.win.set_default_size(int(sensible_allocation.width * 0.95),
            int(sensible_allocation.height * 0.95))
开发者ID:coopengo,项目名称:tryton,代码行数:69,代码来源:win_search.py


示例15: WinSearch

class WinSearch(NoModal):

    def __init__(self, model, callback, sel_multi=True, context=None,
            domain=None, view_ids=None, views_preload=None, new=True):
        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)
        if new and common.MODELACCESS[model]['create']:
            self.but_new = self.win.add_button(gtk.STOCK_NEW,
                gtk.RESPONSE_ACCEPT)
            self.but_new.set_accel_path('<tryton>/Form/New', self.accel_group)

        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)

        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()
        # Prevent to set tree_state
        self.screen.tree_states_done.add(id(self.view))
        sel = self.view.treeview.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

        self.win.set_default_size(700, 500)

        self.register()
        sensible_allocation = self.sensible_widget.get_allocation()
        self.win.set_default_size(int(sensible_allocation.width * 0.95),
            int(sensible_allocation.height * 0.95))

    def sig_activate(self, *args):
        self.view.treeview.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()
        common.center_window(self.win, self.parent, self.sensible_widget)

    def hide(self):
        self.win.hide()

    def response(self, win, response_id):
        res = None
        if response_id == gtk.RESPONSE_OK:
            res = [r.id for r in self.screen.selected_records]
        elif response_id == gtk.RESPONSE_APPLY:
            self.screen.search_filter(self.screen.screen_container.get_text())
            return
        elif response_id == gtk.RESPONSE_ACCEPT:
            screen = Screen(self.model_name, domain=self.domain,
                context=self.context, mode=['form'])

#.........这里部分代码省略.........
开发者ID:coopengo,项目名称:tryton,代码行数:101,代码来源:win_search.py


示例16: __init__

    def __init__(self, attrs=None, context=None):
        super(Action, self).__init__()
        self.act_id = int(attrs['name'])
        self.context = context or {}

        try:
            self.action = RPCExecute('model', 'ir.action.act_window', 'read',
                self.act_id, False)
        except RPCException:
            raise

        view_ids = None
        self.action['view_mode'] = None
        if self.action.get('views', []):
            view_ids = [x[0] for x in self.action['views']]
            self.action['view_mode'] = [x[1] for x in self.action['views']]
        elif self.action.get('view_id', False):
            view_ids = [self.action['view_id'][0]]

        if 'view_mode' in attrs:
            self.action['view_mode'] = attrs['view_mode']

        self.action.setdefault('pyson_domain', '[]')
        self.context.update(rpc.CONTEXT)
        self.context['_user'] = rpc._USER
        self.context.update(PYSONDecoder(self.context).decode(
            self.action.get('pyson_context', '{}')))

        eval_ctx = self.context.copy()
        self.context.update(PYSONDecoder(eval_ctx).decode(
            self.action.get('pyson_context', '{}')))

        self.domain = []
        self.update_domain([])

        search_context = self.context.copy()
        search_context['context'] = self.context
        search_context['_user'] = rpc._USER
        search_value = PYSONDecoder(search_context).decode(
            self.action['pyson_search_value'] or '{}')

        self.widget = gtk.Frame()
        self.widget.set_border_width(0)

        vbox = gtk.VBox(homogeneous=False, spacing=3)
        self.widget.add(vbox)

        self.title = gtk.Label()
        self.widget.set_label_widget(self.title)
        self.widget.set_label_align(0.0, 0.5)
        self.widget.show_all()

        self.screen = Screen(self.action['res_model'],
            mode=self.action['view_mode'], context=self.context,
            view_ids=view_ids, domain=self.domain,
            search_value=search_value, row_activate=self.row_activate)
        vbox.pack_start(self.screen.widget, expand=True, fill=True)
        name = self.screen.current_view.title
        self.screen.signal_connect(self, 'record-message',
            self._active_changed)

        if attrs.get('string'):
            self.title.set_text(attrs['string'])
        elif self.action.get('window_name'):
            self.title.set_text(self.action['name'])
        else:
            self.title.set_text(name)

        self.widget.set_size_request(int(attrs.get('width', -1)),
                int(attrs.get('height', -1)))

        self.screen.search_filter()
开发者ID:mediafactory,项目名称:tryton_client_desktop,代码行数:72,代码来源:action.py


示例17: __init__

    def __init__(self, view, attrs):
        super(Many2Many, self).__init__(view, attrs)

        self.widget = gtk.Frame()
        self.widget.set_shadow_type(gtk.SHADOW_NONE)
        self.widget.get_accessible().set_name(attrs.get('string', ''))
        vbox = gtk.VBox(homogeneous=False, spacing=5)
        self.widget.add(vbox)
        self._readonly = True
        self._position = 0

        hbox = gtk.HBox(homogeneous=False, spacing=0)
        hbox.set_border_width(2)

        label = gtk.Label(attrs.get('string', ''))
        label.set_alignment(0.0, 0.5)
        hbox.pack_start(label, expand=True, fill=True)

        hbox.pack_start(gtk.VSeparator(), expand=False, fill=True)

        tooltips = common.Tooltips()

        self.wid_text = PlaceholderEntry()
        self.wid_text.set_placeholder_text(_('Search'))
        self.wid_text.set_property('width_chars', 13)
        self.wid_text.connect('focus-out-event', lambda *a: self._focus_out())
        self.focus_out = True
        hbox.pack_start(self.wid_text, expand=True, fill=True)

        if int(self.attrs.get('completion', 1)):
            self.wid_completion = get_completion(
                create=self.attrs.get('create', True)
                and common.MODELACCESS[self.attrs['relation']]['create'])
            self.wid_completion.connect('match-selected',
                self._completion_match_selected)
            self.wid_completion.connect('action-activated',
                self._completion_action_activated)
            self.wid_text.set_completion(self.wid_completion)
            self.wid_text.connect('changed', self._update_completion)
        else:
            self.wid_completion = None

        self.but_add = gtk.Button()
        tooltips.set_tip(self.but_add, _('Add existing record'))
        self.but_add.connect('clicked', self._sig_add)
        img_add = gtk.Image()
        img_add.set_from_stock('tryton-list-add',
            gtk.ICON_SIZE_SMALL_TOOLBAR)
        img_add.set_alignment(0.5, 0.5)
        self.but_add.add(img_add)
        self.but_add.set_relief(gtk.RELIEF_NONE)
        hbox.pack_start(self.but_add, expand=False, fill=False)

        self.but_remove = gtk.Button()
        tooltips.set_tip(self.but_remove, _('Remove selected record <Del>'))
        self.but_remove.connect('clicked', self._sig_remove)
        img_remove = gtk.Image()
        img_remove.set_from_stock('tryton-list-remove',
            gtk.ICON_SIZE_SMALL_TOOLBAR)
        img_remove.set_alignment(0.5, 0.5)
        self.but_remove.add(img_remove)
        self.but_remove.set_relief(gtk.RELIEF_NONE)
        hbox.pack_start(self.but_remove, expand=False, fill=False)

        hbox.set_focus_chain([self.wid_text])

        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'],
            view_ids=attrs.get('view_ids', '').split(','),
            mode=['tree'], views_preload=attrs.get('views', {}),
            row_activate=self._on_activate)
        self.screen.signal_connect(self, 'record-message', self._sig_label)

        vbox.pack_start(self.screen.widget, expand=True, fill=True)

        self.screen.widget.connect('key_press_event', self.on_keypress)
        self.wid_text.connect('key_press_event', self.on_keypress)
开发者ID:coopengo,项目名称:tryton,代码行数:86,代码来源:many2many.py


示例18: Many2Many

class Many2Many(WidgetInterface):

    def __init__(self, field_name, model_name, attrs=None):
        super(Many2Many, self).__init__(field_name, model_name, attrs=attrs)

        self.widget = gtk.VBox(homogeneous=False, spacing=5)
        self._readonly = True
        self._position = 0

        hbox = gtk.HBox(homogeneous=False, spacing=0)
        hbox.set_border_width(2)

        label = gtk.Label(attrs.get('string', ''))
        label.set_alignment(0.0, 0.5)
        hbox.pack_start(label, expand=True, fill=True)

        hbox.pack_start(gtk.VSeparator(), expand=False, fill=True)

        tooltips = common.Tooltips()

        self.wid_text = PlaceholderEntry()
        self.wid_text.set_placeholder_text(_('Search'))
        self.wid_text.set_property('width_chars', 13)
        self.wid_text.connect('focus-out-event', lambda *a: self._focus_out())
        self.focus_out = True
        hbox.pack_start(self.wid_text, expand=True, fill=True)

        if int(self.attrs.get('completion', 1)):
            self.wid_completion = get_completion()
            self.wid_completion.connect('match-selected',
                self._completion_match_selected)
            self.wid_completion.connect('action-activated',
                self._completion_action_activated)
            self.wid_text.set_completion(self.wid_completion)
            self.wid_text.connect('changed', self._update_completion)
        else:
            self.wid_completion = None

        self.but_add = gtk.Button()
        tooltips.set_tip(self.but_add, _('Add existing record'))
        self.but_add.connect('clicked', self._sig_add)
        img_add = gtk.Image()
        img_add.set_from_stock('tryton-list-add',
            gtk.ICON_SIZE_SMALL_TOOLBAR)
        img_add.set_alignment(0.5, 0.5)
        self.but_add.add(img_add)
        self.but_add.set_relief(gtk.RELIEF_NONE)
        hbox.pack_start(self.but_add, expand=False, fill=False)

        self.but_remove = gtk.Button()
        tooltips.set_tip(self.but_remove, _('Remove selected record <Del>'))
        self.but_remove.connect('clicked', self._sig_remove)
        img_remove = gtk.Image()
        img_remove.set_from_stock('tryton-list-remove',
            gtk.ICON_SIZE_SMALL_TOOLBAR)
        img_remove.set_alignment(0.5, 0.5)
        self.but_remove.add(img_remove)
        self.but_remove.set_relief(gtk.RELIEF_NONE)
        hbox.pack_start(self.but_remove, expand=False, fill=False)

        hbox.set_focus_chain([self.wid_text])

        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'],
            view_ids=attrs.get('view_ids', '').split(','),
            mode=['tree'], views_preload=attrs.get('views', {}),
            row_activate=self._on_activate)
        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)
        self.wid_text.connect('key_press_event', self.on_keypress)

    def _color_widget(self):
        if hasattr(self.screen.current_view, 'widget_tree'):
            return self.screen.current_view.widget_tree
        return super(Many2Many, self)._color_widget()

    def grab_focus(self):
        return self.wid_text.grab_focus()

    def on_keypress(self, widget, event):
        editable = self.wid_text.get_editable()
        activate_keys = [gtk.keysyms.Tab, gtk.keysyms.ISO_Left_Tab]
        if not self.wid_completion:
            activate_keys.append(gtk.keysyms.Return)
        if event.keyval == gtk.keysyms.F3:
            self._sig_add()
            return True
        if event.keyval == gtk.keysyms.F2 \
                and widget == self.screen.widget:
            self._sig_edit()
            return True
#.........这里部分代码省略.........
开发者ID:sunny414,项目名称:tryton-client,代码行数:101,代码来源:many2many.py


示例19: __init__


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python backend.get函数代码示例发布时间:2022-05-27
下一篇:
Python trace.Annotation类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap