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

Python toolkit.toolkit函数代码示例

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

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



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

示例1: _timer_pop

    def _timer_pop(self):
        """ Handles the timer popping.
        """
        ui = self.ui
        control = ui.control
        if control is None:
            # Looks like someone forgot to tell us that the ui has been closed:
            self.stop()

            return

        # Make sure that the initial distance of the mouse pointer to the
        # control has been set:
        mx, my = toolkit().mouse_position()
        if self.mouse is None:
            self.mouse = (mx, my)
            self.distance = self._distance(mx, my)

        if self.is_activated:
            # Don't close the popup if any mouse buttons are currently pressed:
            if len(toolkit().mouse_buttons()) > 0:
                return

            # Check for the special case of the mouse pointer having to be
            # within the original bounds of the object the popup was created
            # for:
            if self.is_info:
                parent = control._parent
                if isinstance(parent, tuple):
                    px, py, pdx, pdy = parent
                else:
                    px, py = parent.screen_position
                    pdx, pdy = parent.size

                if (mx < px) or (mx >= (px + pdx)) or (my < py) or (my >= (py + pdy)):
                    do_later(ui.owner.close_popup)
                    self.is_activated = False
            else:
                # Allow for a 'dead zone' border around the window to allow for
                # small motor control problems:
                if self._distance(mx, my) > self.border:
                    control_at = toolkit().control_at(mx, my)
                    while control_at is not None:
                        if control_at is control:
                            return

                        control_at = control_at.parent

                    do_later(ui.owner.close_popup)
                    self.is_activated = False
        else:
            distance = self._distance(mx, my)
            if distance == 0:
                # If the pointer is now in the popup view, activate it:
                self.is_activated = True
            elif distance > (self.distance + 25):
                # If the mouse has moved too far away from the popup view, then
                # close it:
                do_later(ui.owner.close_popup)
开发者ID:davidmorrill,项目名称:facets,代码行数:59,代码来源:ui_live.py


示例2: dispose

 def dispose ( self ):
     """ Disposes of the contents of a user interface.
     """
     # Save the user preference information for the user interface:
     toolkit().save_window( self )
     
     # Finish disposing of the user interface:
     self.finish()
开发者ID:pv,项目名称:matplotlib-cvs,代码行数:8,代码来源:ui.py


示例3: prepare_ui

    def prepare_ui ( self ):
        """ Performs all processing that occurs after the user interface is 
        created.
        """
        # Invoke all of the editor 'name_defined' methods we've accumulated:
        info = self.info
        for method in self._defined:
            method( info )

        # Then reset the list, since we don't need it anymore:
        del self._defined[:]

        # Hook all events if the handler is an extended 'ViewHandler':
        handler = self.handler
        if isinstance( handler, ViewHandler ):
            toolkit().hook_events( self, self.control )

        # Invoke the handler's 'init' method, and abort if it indicates failure:
        if handler.init( info ) == False:
            raise TraitError, 'User interface creation aborted'

        # For each Handler method whose name is of the form
        # 'object_name_changed', where 'object' is the name of an object in the
        # UI's 'context', create a trait notification handler that will call
        # the method whenever 'object's 'name' trait changes. Also invoke the
        # method immediately so initial user interface state can be correctly
        # set:
        context = self.context
        for name in self._each_trait_method( handler ):
            if name[-8:] == '_changed':
                prefix = name[:-8]
                col    = prefix.find( '_', 1 )
                if col >= 0:
                    object = context.get( prefix[ : col ] )
                    if object is not None:
                        method     = getattr( handler, name )
                        trait_name = prefix[ col + 1: ]
                        self._dispatchers.append( Dispatcher(
                             method, info, object, trait_name ) )
                        if object.base_trait( trait_name ).type != 'event':
                            method( info )

        # If there are any Editor object's whose 'visible', 'enabled' or
        # 'checked' state is controlled by a 'visible_when', 'enabled_when' or
        # 'checked_when' expression, set up an 'anytrait' changed notification
        # handler on each object in the 'context' that will cause the 'visible',
        # 'enabled' or 'checked' state of each affected Editor to be set. Also
        # trigger the evaluation immediately, so the visible, enabled or checked
        # state of each Editor can be correctly initialized:
        if (len( self._visible ) +
            len( self._enabled ) +
            len( self._checked )) > 0:
            for object in context.values():
                object.on_trait_change( self._evaluate_when, dispatch = 'ui' )
            self._evaluate_when()

        # Indicate that the user interface has been initialized:
        info.initialized = True
开发者ID:gkliska,项目名称:razvoj,代码行数:58,代码来源:ui.py


示例4: dispose

    def dispose ( self, result = None, abort = False ):
        """ Disposes of the contents of a user interface.
        """
        # Save the user preference information for the user interface:
        if not abort:
            toolkit().save_window( self )

        # Finish disposing of the user interface:
        self.finish( result )
开发者ID:gkliska,项目名称:razvoj,代码行数:9,代码来源:ui.py


示例5: set_error_state

    def set_error_state ( self, state = None, control = None ):
        """ Sets the editor's current error state.
        """
        from facets.ui.colors import OKColor, ErrorColor

        state = self.get_error_state( state )

        if control is None:
            control = self.get_error_control()

        controls = control
        if not isinstance( control, list ):
            controls = [ control ]

        for control in controls:
            # fixme: Eventually this code should not be necessary...
            control    = toolkit().as_toolkit_adapter( control )
            ui_control = control()
            if state:
                color = ErrorColor
                if getattr( ui_control, '_ok_color', None ) is None:
                    ui_control._ok_color = control.background_color
            else:
                color = getattr( ui_control, '_ok_color', None )
                if color is None:
                    color = OKColor
                    if control.is_panel:
                        color = WindowColor

            control.background_color = color
            control.refresh()
开发者ID:davidmorrill,项目名称:facets,代码行数:31,代码来源:editor.py


示例6: CodeEditor

def CodeEditor(*args, **facets):
    """ Allows the user to edit a multi-line string.

        The "simple" and "custom" styles of this editor display multiple lines
        of the string, with line numbers.
    """
    return toolkit().code_editor(*args, **facets)
开发者ID:davidmorrill,项目名称:facets,代码行数:7,代码来源:core_editors.py


示例7: init

    def init(self, parent):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        if (self.item.resizable is True) or (self.item.height != -1.0):
            self.adapter = (
                toolkit()
                .create_text_input(parent, read_only=True, multi_line=True)
                .set(value=self.str_value, background_color=WindowColor)
            )
        else:
            self.adapter = toolkit().create_label(parent).set(value=self.str_value)
            # fixme: How to do this in GUI toolkit neutral manner?...
            ###self.layout_style = 0

        self.set_tooltip()
开发者ID:davidmorrill,项目名称:facets,代码行数:16,代码来源:editor_factory.py


示例8: CheckListEditor

def CheckListEditor ( *args, **traits ):
    """ Allows the user to select zero, one, or more values from a finite set of
        possibilities.

        Note that the "simple" style is limited to selecting a single value.
    """
    return toolkit().check_list_editor( *args, **traits )
开发者ID:gkliska,项目名称:razvoj,代码行数:7,代码来源:editors.py


示例9: TextEditor

def TextEditor ( *args, **traits ):
    """ Allows the user to modify a text string.

        The string value entered by the user is coerced to the appropriate type
        for the trait attribute being modified.
    """
    return toolkit().text_editor( *args, **traits )
开发者ID:gkliska,项目名称:razvoj,代码行数:7,代码来源:editors.py


示例10: ListEditor

def ListEditor(*args, **facets):
    """ Allows the user to modify a list of values.

        The user can add, delete, or reorder items, or change the content of
        items.
    """
    return toolkit().list_editor(*args, **facets)
开发者ID:davidmorrill,项目名称:facets,代码行数:7,代码来源:core_editors.py


示例11: _label_control_set

 def _label_control_set ( self, control ):
     """ Handles the 'label_control' facet being changed.
     """
     if control is None:
         self.label_adapter = None
     elif ((self.label_adapter is None) or
           (self.label_adapter() is not control)):
         self.label_adapter = toolkit().control_adapter_for( control )
开发者ID:davidmorrill,项目名称:facets,代码行数:8,代码来源:editor.py


示例12: _control_set

 def _control_set ( self, control ):
     """ Handles the 'control' facet being changed.
     """
     if control is None:
         self.adapter = None
     elif (self.adapter is None) or (self.adapter() is not control):
         self.adapter    = toolkit().adapter_for( control )
         control._editor = self
开发者ID:davidmorrill,项目名称:facets,代码行数:8,代码来源:editor.py


示例13: ui

 def ui ( self, parent, kind ):
     """ Creates a user interface from the associated View template object.
     """
     if (parent is None) and (kind in kind_must_have_parent):
         kind = 'live'
     self.rebuild = getattr( toolkit(), 'ui_' + kind )
     self.rebuild( self, parent )
     self.view.on_trait_change( self._updated_changed, 'updated',
                                dispatch = 'ui' )
开发者ID:gkliska,项目名称:razvoj,代码行数:9,代码来源:ui.py


示例14: EnumEditor

def EnumEditor(*args, **facets):
    """ Allows the user to select a single value from an enumerated list of
        values.
    """
    # from facets.ui.editors.enum_editor import EnumEditor
    #
    # return EnumEditor( *args, **facets )

    return toolkit().enum_editor(*args, **facets)
开发者ID:davidmorrill,项目名称:facets,代码行数:9,代码来源:core_editors.py


示例15: facets_init

    def facets_init(self):
        """ Completes the initialization of the object.
        """
        kind = self.ui.view.kind
        self.is_activated = self.is_info = kind == "info"
        if kind == "popup":
            self.border = 10

        self.timer = toolkit().create_timer(100, self._timer_pop)
开发者ID:davidmorrill,项目名称:facets,代码行数:9,代码来源:ui_live.py


示例16: ui

    def ui ( self, parent ):
        """ Creates a user interface from the associated View template object.
        """
        if (parent is None) and (self.kind in kind_must_have_parent):
            self.kind = 'live'

        self.view.on_facet_set( self._updated_set, 'updated', dispatch = 'ui' )
        self.rebuild = getattr( self, '_create_' + self.kind )
        self.rebuild( self, toolkit().as_toolkit_adapter( parent ) )
开发者ID:davidmorrill,项目名称:facets,代码行数:9,代码来源:ui.py


示例17: init

    def init ( self, parent ):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        factory             = self.factory
        self.editor_control = control = factory.klass()
        control.factory     = factory
        control.editor      = self
        control.init()

        scroller = None
        if control.virtual_size != UndefinedSize:
            scroller = parent = toolkit().create_scrolled_panel( parent )

        control.parent  = parent
        control.theme   = factory.theme
        ui_control      = control()
        fixed_size      = control.fixed_size
        self.scrollable = (fixed_size == UndefinedSize)

        if factory.refresh != '':
            control.on_facet_set( control.refresh, factory.refresh )

        if scroller is not None:
            control.scroll_control  = scroller
            scroller.content        = ui_control
            ui_control.virtual_size = control.virtual_size
            ui_control              = scroller

        if fixed_size != UndefinedSize:
            ui_control.min_size = fixed_size

        self.adapter = ui_control

        if self.extended_name != 'None':
            object = self.context_object
            name   = self.extended_name
            if not hasattr( control, 'value' ):
                if isinstance( object, BaseEditor ) and (name == 'value'):
                    # FIXME: Handle the special case of an Editor's 'value'
                    # facet, which is a property, which doesn't work well as is,
                    # so we reach down into the editor to extract the actual
                    # object facet being referenced:
                    name   = object.name
                    object = object.object

                control.add_facet( 'value', object.facet( name ) )

            object.sync_facet( name, control, 'value', True )

        self.set_tooltip()
        control.post_init()
开发者ID:davidmorrill,项目名称:facets,代码行数:52,代码来源:custom_control_editor.py


示例18: position

 def position ( self, info ):
     """ Positions a dialog-based user interface on the display.
     
     Parameters
     ----------
     info : UIInfo object
         The UIInfo object associated with the window
         
     Returns
     -------
     Nothing.
         
     Description
     -----------
     This method is called after the user interface is initialized (by
     calling init()), but before the user interface is displayed. Override
     this method to position the window on the display device. The default
     implementation calls the position() method of the current toolkit.
     
     Usually, you do not need to override this method, because you can 
     control the window's placement using the **x** and **y** attributes
     of the View object.
     """
     toolkit().position( info.ui )
开发者ID:gkliska,项目名称:razvoj,代码行数:24,代码来源:handler.py


示例19: CompoundEditor

def CompoundEditor ( *args, **traits ):
    """ Allows the user to select a value based on a compound trait.

    Because a compound trait is composed of multiple trait definitions, this
    editor factory displays trait editors for each of the constituent traits.
    For example, consider the following trait attribute, defined as a compound
    that accepts integer values in the range of 1 to 6, or text strings
    corresponding to those integers::

        compound = Trait(1, Range(1, 6), 'one', 'two', 'three', 'four',
                            'five', 'six')

    The editor displayed for this trait attribute combines editors for integer
    ranges and for enumerations.
    """
    return toolkit().compound_editor( *args, **traits )
开发者ID:gkliska,项目名称:razvoj,代码行数:16,代码来源:editors.py


示例20: __getstate__

    def __getstate__(self):
        ftc = toolkit().from_toolkit_color

        return {
            "image": str(self.image),
            "tiled": self.tiled,
            "origin": self.origin,
            "border": eval(str(self.border)),
            "content": eval(str(self.content)),
            "label": eval(str(self.label)),
            "alignment": self.alignment,
            "content_font": str(self.content_font),
            "label_font": str(self.label_font),
            "content_color": ftc(self.content_color),
            "label_color": ftc(self.label_color),
            "bg_color": ftc(self.bg_color),
        }
开发者ID:davidmorrill,项目名称:facets,代码行数:17,代码来源:theme.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python tools.boot_manifest函数代码示例发布时间:2022-05-27
下一篇:
Python toolkit.response函数代码示例发布时间: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