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

Python api.raise_to_debug函数代码示例

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

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



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

示例1: update_object

    def update_object(self, event):
        """ Handles the user selecting a new value from the combo box.
        """
        self._no_enum_update += 1
        try:
            new_value = self.mapping[event.GetString()]
            if new_value == self.value and self.factory.is_grid_cell:
                # If the enum editor is in a grid cell and the value did not
                # change, we want the enum editor to go away, reverting back to
                # the normal cell appearance. This is for 2 reasons:
                #  1. it looks nicer
                #  2. if the grid id suddenly closed, wx freaks & causes a
                #     segfault

                grid = self.control.Parent.Parent
                grid.EnableEditing(False)
                grid.EnableEditing(True)

            self.value = new_value

        except:
            from traitsui.api import raise_to_debug

            raise_to_debug()

        self._no_enum_update -= 1
开发者ID:gdsylzj,项目名称:traitsui,代码行数:26,代码来源:enum_editor.py


示例2: _perform

    def _perform(self, action):
        method_name = action.action
        info = self._menu_context['info']
        handler = self._menu_context['handler']
        object = self._menu_context['object']
        selection = self._menu_context['selection']
        self._menu_context['action'] = action

        if method_name.find('.') >= 0:
            if method_name.find('(') < 0:
                method_name += '()'
            try:
                eval(method_name, globals(), self._menu_context)
            except:
                from traitsui.api import raise_to_debug
                raise_to_debug()
            return

        method = getattr(handler, method_name, None)
        if method is not None:
            method(info, selection)
            return

        if action.on_perform is not None:
            action.on_perform(selection)

        action.perform(selection)
开发者ID:jonathanrocher,项目名称:traitsui,代码行数:27,代码来源:editor.py


示例3: can_add_to_menu

    def can_add_to_menu(self, action):
        """ Returns whether the action should be defined in the user interface.
        """
        if action.defined_when != '':

            try:
                if not eval(
                        action.defined_when,
                        globals(),
                        self._menu_context):
                    return False
            except:
                from traitsui.api import raise_to_debug
                raise_to_debug()

        if action.visible_when != '':
            try:
                if not eval(
                        action.visible_when,
                        globals(),
                        self._menu_context):
                    return False
            except:
                from traitsui.api import raise_to_debug
                raise_to_debug()

        return True
开发者ID:jonathanrocher,项目名称:traitsui,代码行数:27,代码来源:editor.py


示例4: redo

 def redo(self):
     """ Re-does the change.
     """
     try:
         setattr(self.object, self.name, self.new_value)
     except Exception:
         from traitsui.api import raise_to_debug
         raise_to_debug()
开发者ID:bergtholdt,项目名称:traitsui,代码行数:8,代码来源:undo.py


示例5: get_raw_value

 def get_raw_value(self, object):
     """ Gets the unformatted value of the column for a specified object.
     """
     try:
         return xgetattr(self.get_object(object), self.name)
     except Exception as e:
         from traitsui.api import raise_to_debug
         raise_to_debug()
         return None
开发者ID:bergtholdt,项目名称:traitsui,代码行数:9,代码来源:table_column.py


示例6: update_object_on_scroll

 def update_object_on_scroll(self, pos):
     """ Handles the user changing the current slider value.
     """
     value = self._convert_from_slider(pos)
     self.control.text.setText(self.format % value)
     try:
         self.value = value
     except Exception as exc:
         from traitsui.api import raise_to_debug
         raise_to_debug()
开发者ID:bergtholdt,项目名称:traitsui,代码行数:10,代码来源:range_editor.py


示例7: update_object

 def update_object(self, text):
     """ Handles the user selecting a new value from the combo box.
     """
     if self._no_enum_update == 0:
         self._no_enum_update += 1
         try:
             self.value = self.mapping[six.text_type(text)]
         except Exception:
             from traitsui.api import raise_to_debug
             raise_to_debug()
         self._no_enum_update -= 1
开发者ID:enthought,项目名称:traitsui,代码行数:11,代码来源:enum_editor.py


示例8: editor_trait_modified

 def editor_trait_modified ( new ):
     # Need this to include 'user_object' in closure:
     user_object
     if key not in self._no_trait_update:
         self._no_trait_update[ key ] = None
         try:
             setattr( eval( user_ref ), user_name, new )
         except:
             from traitsui.api import raise_to_debug
             raise_to_debug()
         del self._no_trait_update[ key ]
开发者ID:FelixHartmann,项目名称:traitsui,代码行数:11,代码来源:editor.py


示例9: user_list_modified

 def user_list_modified ( event ):
     if isinstance( event, TraitListEvent ):
         if key not in self._no_trait_update:
             self._no_trait_update[ key ] = None
             n = event.index
             try:
                 getattr( self, editor_name )[
                     n: n + len(event.removed)] = event.added
             except:
                 from traitsui.api import raise_to_debug
                 raise_to_debug()
             del self._no_trait_update[ key ]
开发者ID:FelixHartmann,项目名称:traitsui,代码行数:12,代码来源:editor.py


示例10: _selected_changed

 def _selected_changed(self, new):
     if not self._no_update:
         if new is None:
             self._selected_row_changed(-1)
         else:
             try:
                 selected_row = self.value.index(new)
             except Exception:
                 from traitsui.api import raise_to_debug
                 raise_to_debug()
             else:
                 self._selected_row_changed(selected_row)
开发者ID:bergtholdt,项目名称:traitsui,代码行数:12,代码来源:tabular_editor.py


示例11: update_editor

 def update_editor(self):
     """ Updates the editor when the object trait changes externally to the
         editor.
     """
     if not self._locked:
         blocked = self.control.blockSignals(True)
         try:
             self.control.setValue(int(self.value))
         except Exception:
             from traitsui.api import raise_to_debug
             raise_to_debug()
         finally:
             self.control.blockSignals(blocked)
开发者ID:bergtholdt,项目名称:traitsui,代码行数:13,代码来源:range_editor.py


示例12: editor_list_modified

 def editor_list_modified ( event ):
     # Need this to include 'user_object' in closure:
     user_object
     if key not in self._no_trait_update:
         self._no_trait_update[ key ] = None
         n = event.index
         try:
             eval( user_value )[ n:
                 n + len( event.removed ) ] = event.added
         except:
             from traitsui.api import raise_to_debug
             raise_to_debug()
         del self._no_trait_update[ key ]
开发者ID:FelixHartmann,项目名称:traitsui,代码行数:13,代码来源:editor.py


示例13: eval_when

    def eval_when(self, when, result=True):
        """ Evaluates an expression in the UI's **context** and returns the
            result.
        """
        context = self._get_context(self.context)
        try:
            result = eval(when, globals(), context)
        except:
            from traitsui.api import raise_to_debug
            raise_to_debug()

        del context['ui']

        return result
开发者ID:jonathanrocher,项目名称:traitsui,代码行数:14,代码来源:ui.py


示例14: eval_when

 def eval_when(self, condition, object, trait):
     """ Evaluates a condition within a defined context, and sets a
     specified object trait based on the result, which is assumed to be a
     Boolean.
     """
     if condition != '':
         value = True
         try:
             if not eval(condition, globals(), self._menu_context):
                 value = False
         except:
             from traitsui.api import raise_to_debug
             raise_to_debug()
         setattr(object, trait, value)
开发者ID:jonathanrocher,项目名称:traitsui,代码行数:14,代码来源:editor.py


示例15: _evaluate_condition

    def _evaluate_condition ( self, conditions, trait ):
        """ Evaluates a list of (eval,editor) pairs and sets a specified trait
        on each editor to reflect the Boolean value of the expression.
        """
        context = self._get_context( self.context )
        for when, editor in conditions:
            value = True
            try:
                if not eval( when, globals(), context ):
                    value = False
            except:
                from traitsui.api import raise_to_debug
                raise_to_debug()

            setattr( editor, trait, value )
开发者ID:GaelVaroquaux,项目名称:traitsui,代码行数:15,代码来源:ui.py


示例16: sync_value

    def sync_value ( self, user_name, editor_name, mode = 'both',
                           is_list = False ):
        """ Sets or unsets synchronization between an editor trait and a user
            object trait.
        """
        if user_name != '':
            key = '%s:%s' % ( user_name, editor_name )

            if self._no_trait_update is None:
                self._no_trait_update = {}

            user_ref = 'user_object'
            col      = user_name.find( '.' )
            if col < 0:
                user_object = self.context_object
                xuser_name  = user_name
            else:
                user_object = self.ui.context[ user_name[ : col ] ]
                user_name   = xuser_name = user_name[ col + 1: ]
                col         = user_name.rfind( '.' )
                if col >= 0:
                    user_ref += ('.' + user_name[ : col ])
                    user_name = user_name[ col + 1: ]

            user_value = compile( '%s.%s' % ( user_ref, user_name ),
                                  '<string>', 'eval' )
            user_ref   = compile( user_ref, '<string>', 'eval' )

            if mode in ( 'from', 'both' ):

                def user_trait_modified ( new ):
                    # Need this to include 'user_object' in closure:
                    user_object
                    if key not in self._no_trait_update:
                        self._no_trait_update[ key ] = None
                        try:
                            setattr( self, editor_name, new )
                        except:
                            from traitsui.api import raise_to_debug
                            raise_to_debug()
                        del self._no_trait_update[ key ]

                user_object.on_trait_change( user_trait_modified, xuser_name )

                if self._user_to is None:
                    self._user_to = []
                self._user_to.append( ( user_object, xuser_name,
                                        user_trait_modified ) )

                if is_list:

                    def user_list_modified ( event ):
                        if isinstance( event, TraitListEvent ):
                            if key not in self._no_trait_update:
                                self._no_trait_update[ key ] = None
                                n = event.index
                                try:
                                    getattr( self, editor_name )[
                                        n: n + len(event.removed)] = event.added
                                except:
                                    from traitsui.api import raise_to_debug
                                    raise_to_debug()
                                del self._no_trait_update[ key ]

                    user_object.on_trait_change( user_list_modified,
                                    xuser_name + '_items' )
                    self._user_to.append( ( user_object, xuser_name + '_items',
                                            user_list_modified ) )

                try:
                    setattr( self, editor_name, eval( user_value ) )
                except:
                    from traitsui.api import raise_to_debug
                    raise_to_debug()

            if mode in ( 'to', 'both' ):

                def editor_trait_modified ( new ):
                    # Need this to include 'user_object' in closure:
                    user_object
                    if key not in self._no_trait_update:
                        self._no_trait_update[ key ] = None
                        try:
                            setattr( eval( user_ref ), user_name, new )
                        except:
                            from traitsui.api import raise_to_debug
                            raise_to_debug()
                        del self._no_trait_update[ key ]

                self.on_trait_change( editor_trait_modified, editor_name )

                if self._user_from is None:
                    self._user_from = []
                self._user_from.append( ( editor_name, editor_trait_modified ) )

                if is_list:

                    def editor_list_modified ( event ):
                        # Need this to include 'user_object' in closure:
                        user_object
#.........这里部分代码省略.........
开发者ID:FelixHartmann,项目名称:traitsui,代码行数:101,代码来源:editor.py


示例17: _evaluate_condition

    def _evaluate_condition(self, conditions, trait, at_init=False):
        """ Evaluates a list of (eval, editor) pairs and sets a specified trait
        on each editor to reflect the Boolean value of the expression.

        1) All conditions are evaluated
        2) The elements whose condition evaluates to False are updated
        3) The elements whose condition evaluates to True are updated

        E.g., we first make invisible all elements for which 'visible_when'
        evaluates to False, and then we make visible the ones
        for which 'visible_when' is True. This avoids mutually exclusive
        elements to be visible at the same time, and thus making a dialog
        unnecessarily large.

        The state of an editor is updated only when it changes, unless
        at_init is set to True.

        Parameters
        ----------
        conditions : list of (str, Editor) tuple
            A list of tuples, each formed by 1) a string that contains a
            condition that evaluates to either True or False, and
            2) the editor whose state depends on the condition

        trait : str
            The trait that is set by the condition.
            Either 'visible, 'enabled', or 'checked'.

        at_init : bool
            If False, the state of an editor is set only when it changes
            (e.g., a visible element would not be updated to visible=True
            again). If True, the state is always updated (used at
            initialization).
        """

        context = self._get_context(self.context)

        # list of elements that should be activated
        activate = []
        # list of elements that should be de-activated
        deactivate = []

        for when, editor in conditions:
            try:
                cond_value = eval(when, globals(), context)
                editor_state = getattr(editor, trait)

                # add to update lists only if at_init is True (called on
                # initialization), or if the editor state has to change

                if cond_value and (at_init or not editor_state):
                    activate.append(editor)

                if not cond_value and (at_init or editor_state):
                    deactivate.append(editor)

            except Exception:
                # catch errors in the validate_when expression
                from traitsui.api import raise_to_debug
                raise_to_debug()

        # update the state of the editors
        for editor in deactivate:
            setattr(editor, trait, False)
        for editor in activate:
            setattr(editor, trait, True)
开发者ID:jonathanrocher,项目名称:traitsui,代码行数:66,代码来源:ui.py


示例18: sync_value

    def sync_value(self, user_name, editor_name, mode="both", is_list=False):
        """ Sets or unsets synchronization between an editor trait and a user
            object trait.
        """
        if user_name != "":
            key = "%s:%s" % (user_name, editor_name)

            if self._no_trait_update is None:
                self._no_trait_update = {}

            user_ref = "user_object"
            col = user_name.find(".")
            if col < 0:
                user_object = self.context_object
                xuser_name = user_name
            else:
                user_object = self.ui.context[user_name[:col]]
                user_name = xuser_name = user_name[col + 1 :]
                col = user_name.rfind(".")
                if col >= 0:
                    user_ref += "." + user_name[:col]
                    user_name = user_name[col + 1 :]

            user_value = compile("%s.%s" % (user_ref, user_name), "<string>", "eval")
            user_ref = compile(user_ref, "<string>", "eval")

            if mode in ("from", "both"):

                def user_trait_modified(new):
                    # Need this to include 'user_object' in closure:
                    user_object
                    if key not in self._no_trait_update:
                        self._no_trait_update[key] = None
                        try:
                            setattr(self, editor_name, new)
                        except:
                            from traitsui.api import raise_to_debug

                            raise_to_debug()
                        del self._no_trait_update[key]

                user_object.on_trait_change(user_trait_modified, xuser_name)

                if self._user_to is None:
                    self._user_to = []
                self._user_to.append((user_object, xuser_name, user_trait_modified))

                if is_list:

                    def user_list_modified(event):
                        if isinstance(event, TraitListEvent):
                            if key not in self._no_trait_update:
                                self._no_trait_update[key] = None
                                n = event.index
                                try:
                                    getattr(self, editor_name)[n : n + len(event.removed)] = event.added
                                except:
                                    from traitsui.api import raise_to_debug

                                    raise_to_debug()
                                del self._no_trait_update[key]

                    user_object.on_trait_change(user_list_modified, xuser_name + "_items")
                    self._user_to.append((user_object, xuser_name + "_items", user_list_modified))

                try:
                    setattr(self, editor_name, eval(user_value))
                except:
                    from traitsui.api import raise_to_debug

                    raise_to_debug()

            if mode in ("to", "both"):

                def editor_trait_modified(new):
                    # Need this to include 'user_object' in closure:
                    user_object
                    if key not in self._no_trait_update:
                        self._no_trait_update[key] = None
                        try:
                            setattr(eval(user_ref), user_name, new)
                        except:
                            from traitsui.api import raise_to_debug

                            raise_to_debug()
                        del self._no_trait_update[key]

                self.on_trait_change(editor_trait_modified, editor_name)

                if self._user_from is None:
                    self._user_from = []
                self._user_from.append((editor_name, editor_trait_modified))

                if is_list:

                    def editor_list_modified(event):
                        # Need this to include 'user_object' in closure:
                        user_object
                        if key not in self._no_trait_update:
                            self._no_trait_update[key] = None
#.........这里部分代码省略.........
开发者ID:robmcmullen,项目名称:traitsui,代码行数:101,代码来源:editor.py


示例19: sync_value

    def sync_value(self, user_name, editor_name, mode='both',
                   is_list=False, is_event=False):
        """
        Set up synchronization between an editor trait and a user object
        trait.

        Also sets the initial value of the editor trait from the
        user object trait (for modes 'from' and 'both'), and the initial
        value of the user object trait from the editor trait (for mode
        'to').

        Parameters
        ----------
        user_name : string
            The name of the trait to be used on the user object. If empty, no
            synchronization will be set up.
        editor_name : string
            The name of the relevant editor trait.
        mode : string, optional; one of 'to', 'from' or 'both'
            The direction of synchronization. 'from' means that trait changes
            in the user object should be propagated to the editor. 'to' means
            that trait changes in the editor should be propagated to the user
            object. 'both' means changes should be propagated in both
            directions. The default is 'both'.
        is_list : bool, optional
            If true, synchronization for item events will be set up in
            addition to the synchronization for the object itself.
            The default is False.
        is_event : bool, optional
            If true, this method won't attempt to initialize the user
            object or editor trait values. The default is False.
        """
        if user_name != '':
            key = '%s:%s' % (user_name, editor_name)

            if self._no_trait_update is None:
                self._no_trait_update = {}

            user_ref = 'user_object'
            col = user_name.find('.')
            if col < 0:
                user_object = self.context_object
                xuser_name = user_name
            else:
                user_object = self.ui.context[user_name[: col]]
                user_name = xuser_name = user_name[col + 1:]
                col = user_name.rfind('.')
                if col >= 0:
                    user_ref += ('.' + user_name[: col])
                    user_name = user_name[col + 1:]

            user_value = compile('%s.%s' % (user_ref, user_name),
                                 '<string>', 'eval')
            user_ref = compile(user_ref, '<string>', 'eval')

            if mode in ('from', 'both'):

                def user_trait_modified(new):
                    # Need this to include 'user_object' in closure:
                    user_object
                    if key not in self._no_trait_update:
                        self._no_trait_update[key] = None
                        try:
                            setattr(self, editor_name, new)
                        except:
                            from traitsui.api import raise_to_debug
                            raise_to_debug()
                        del self._no_trait_update[key]

                user_object.on_trait_change(user_trait_modified, xuser_name)

                if self._user_to is None:
                    self._user_to = []
                self._user_to.append((user_object, xuser_name,
                                      user_trait_modified))

                if is_list:

                    def user_list_modified(event):
                        if isinstance(event, TraitListEvent):
                            if key not in self._no_trait_update:
                                self._no_trait_update[key] = None
                                n = event.index
                                try:
                                    getattr(self, editor_name)[
                                        n: n + len(event.removed)] = event.added
                                except:
                                    from traitsui.api import raise_to_debug
                                    raise_to_debug()
                                del self._no_trait_update[key]

                    user_object.on_trait_change(user_list_modified,
                                                xuser_name + '_items')
                    self._user_to.append((user_object, xuser_name + '_items',
                                          user_list_modified))

                if not is_event:
                    try:
                        setattr(self, editor_name, eval(user_value))
                    except:
#.........这里部分代码省略.........
开发者ID:bergtholdt,项目名称:traitsui,代码行数:101,代码来源:editor.py



注:本文中的traitsui.api.raise_to_debug函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python clipboard.PyMimeData类代码示例发布时间:2022-05-27
下一篇:
Python importstring.import_item函数代码示例发布时间: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