當前位置: 首頁>>代碼示例>>Python>>正文


Python kivy.properties方法代碼示例

本文整理匯總了Python中kivy.properties方法的典型用法代碼示例。如果您正苦於以下問題:Python kivy.properties方法的具體用法?Python kivy.properties怎麽用?Python kivy.properties使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在kivy的用法示例。


在下文中一共展示了kivy.properties方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: create_view

# 需要導入模塊: import kivy [as 別名]
# 或者: from kivy import properties [as 別名]
def create_view(self, index, viewclass=None):
        """Creates and initializes the view for the data at `index`. The
        returned view is synced with the data, except for the pos/size
        properties.
        """
        if viewclass is None:
            viewclass = self.get_viewclass(index)
        if viewclass is None:
            return
        item = self[index]
        # FIXME: we could pass the data though the constructor, but that wont
        # work for kv-declared classes, and might lead the user to think it can
        # work for reloading as well.
        view = viewclass()
        if viewclass not in _view_base_cache:
            _view_base_cache[viewclass] = isinstance(view, RecycleViewMixin)

        if _view_base_cache[viewclass]:
            view.refresh_view_attrs(self.recycleview, item)
        else:
            for key, value in item.items():
                setattr(view, key, value)
        return view 
開發者ID:kivy-garden,項目名稱:garden.recycleview,代碼行數:25,代碼來源:recycleview.py

示例2: _init_toolbar

# 需要導入模塊: import kivy [as 別名]
# 或者: from kivy import properties [as 別名]
def _init_toolbar(self):
        '''A Toolbar is created with an ActionBar widget in which buttons are
           added with a specific behavior given by a callback. The buttons
           properties are given by matplotlib.
        '''
        basedir = os.path.join(rcParams['datapath'], 'images')
        actionview = ActionView()
        actionprevious = ActionPrevious(title="Navigation", with_previous=False)
        actionoverflow = ActionOverflow()
        actionview.add_widget(actionprevious)
        actionview.add_widget(actionoverflow)
        actionview.use_separator = True
        self.actionbar.add_widget(actionview)
        id_group = uuid.uuid4()
        for text, tooltip_text, image_file, callback in self.toolitems:
            if text is None:
                actionview.add_widget(ActionSeparator())
                continue
            fname = os.path.join(basedir, image_file + '.png')
            if text in ['Pan', 'Zoom']:
                action_button = ActionToggleButton(text=text, icon=fname,
                                                   group=id_group)
            else:
                action_button = ActionButton(text=text, icon=fname)
            action_button.bind(on_press=getattr(self, callback))
            actionview.add_widget(action_button) 
開發者ID:kivy-garden,項目名稱:garden.matplotlib,代碼行數:28,代碼來源:backend_kivy.py

示例3: show_widget_info

# 需要導入模塊: import kivy [as 別名]
# 或者: from kivy import properties [as 別名]
def show_widget_info(self):
        self.content.clear_widgets()
        widget = self.widget
        treeview = self.treeview
        for node in list(treeview.iterate_all_nodes())[:]:
            node.widget_ref = None
            treeview.remove_node(node)
        if not widget:
            if self.at_bottom:
                Animation(top=60, t='out_quad', d=.3).start(self.layout)
            else:
                Animation(y=self.height - 60, t='out_quad', d=.3).start(
                    self.layout)
            self.widget_info = False
            return
        self.widget_info = True
        if self.at_bottom:
            Animation(top=250, t='out_quad', d=.3).start(self.layout)
        else:
            Animation(top=self.height, t='out_quad', d=.3).start(self.layout)
        for node in list(treeview.iterate_all_nodes())[:]:
            treeview.remove_node(node)

        keys = list(widget.properties().keys())
        keys.sort()
        node = None
        wk_widget = weakref.ref(widget)
        for key in keys:
            text = '%s' % key
            node = TreeViewProperty(text=text, key=key, widget_ref=wk_widget)
            node.bind(is_selected=self.show_property)
            try:
                widget.bind(**{key: partial(
                    self.update_node_content, weakref.ref(node))})
            except:
                pass
            treeview.add_node(node) 
開發者ID:BillBillBillBill,項目名稱:Tickeys-linux,代碼行數:39,代碼來源:inspector.py

示例4: get_views

# 需要導入模塊: import kivy [as 別名]
# 或者: from kivy import properties [as 別名]
def get_views(self, i_start, i_end):
        '''Gets a 2-tuple of the new and old views for the current viewport.
        The new views are synced to the data except for the size/pos
        properties.
        The old views need to be removed from the layout, and the new views
        added.
        '''
        current_views = self.views
        visible_views = {}
        new_views = []
        dirty_views = self.dirty_views
        get_view = self.get_view
        make_view_dirty = self.make_view_dirty

        # iterate though the visible view
        # add them into the container if not already done
        for index in range(i_start, i_end + 1):
            view = get_view(index)
            if not view:
                continue

            visible_views[index] = view
            current_views.pop(index, None)
            new_views.append((view, index))

        # put all the hidden view as dirty views
        for index, view in current_views.items():
            make_view_dirty(view, index)
        # save the current visible views
        self.views = visible_views
        return new_views, current_views.values() 
開發者ID:kivy-garden,項目名稱:garden.recycleview,代碼行數:33,代碼來源:recycleview.py

示例5: __init__

# 需要導入模塊: import kivy [as 別名]
# 或者: from kivy import properties [as 別名]
def __init__(self, **kwargs):
        super(StatusLabel, self).__init__(**kwargs)
        self.shorten = False

# Simple extension of Kivy's TreeViewLabel so we can add on our own properties
# to it for easier view tracking 
開發者ID:autosportlabs,項目名稱:RaceCapture_App,代碼行數:8,代碼來源:statusview.py

示例6: draw_path_collection

# 需要導入模塊: import kivy [as 別名]
# 或者: from kivy import properties [as 別名]
def draw_path_collection(self, gc, master_transform, paths, all_transforms,
        offsets, offsetTrans, facecolors, edgecolors,
        linewidths, linestyles, antialiaseds, urls,
        offset_position):
        '''Draws a collection of paths selecting drawing properties from
           the lists *facecolors*, *edgecolors*, *linewidths*,
           *linestyles* and *antialiaseds*. *offsets* is a list of
           offsets to apply to each of the paths. The offsets in
           *offsets* are first transformed by *offsetTrans* before being
           applied.  *offset_position* may be either "screen" or "data"
           depending on the space that the offsets are in.
        '''
        len_path = len(paths[0].vertices) if len(paths) > 0 else 0
        uses_per_path = self._iter_collection_uses_per_path(
            paths, all_transforms, offsets, facecolors, edgecolors)
        # check whether an optimization is needed by calculating the cost of
        # generating and use a path with the cost of emitting a path in-line.
        should_do_optimization = \
            len_path + uses_per_path + 5 < len_path * uses_per_path
        if not should_do_optimization:
            return RendererBase.draw_path_collection(
                self, gc, master_transform, paths, all_transforms,
                offsets, offsetTrans, facecolors, edgecolors,
                linewidths, linestyles, antialiaseds, urls,
                offset_position)
        # Generate an array of unique paths with the respective transformations
        path_codes = []
        for i, (path, transform) in enumerate(self._iter_collection_raw_paths(
            master_transform, paths, all_transforms)):
            transform = Affine2D(transform.get_matrix()).scale(1.0, -1.0)
            if _mpl_ge_2_0:
                polygons = path.to_polygons(transform, closed_only=False)
            else:
                polygons = path.to_polygons(transform)
            path_codes.append(polygons)
        # Apply the styles and rgbFace to each one of the raw paths from
        # the list. Additionally a transformation is being applied to
        # translate each independent path
        for xo, yo, path_poly, gc0, rgbFace in self._iter_collection(
            gc, master_transform, all_transforms, path_codes, offsets,
            offsetTrans, facecolors, edgecolors, linewidths, linestyles,
            antialiaseds, urls, offset_position):
            list_canvas_instruction = self.get_path_instructions(gc0, path_poly,
                                    closed=True, rgbFace=rgbFace)
            for widget, instructions in list_canvas_instruction:
                widget.canvas.add(PushMatrix())
                widget.canvas.add(Translate(xo, yo))
                widget.canvas.add(instructions)
                widget.canvas.add(PopMatrix()) 
開發者ID:kivy-garden,項目名稱:garden.matplotlib,代碼行數:51,代碼來源:backend_kivy.py

示例7: get_view

# 需要導入模塊: import kivy [as 別名]
# 或者: from kivy import properties [as 別名]
def get_view(self, index):
        """Returns a view instance for the data at `index`. It looks through
        the various caches and finally creates a view if it doesn't exist.
        The returned view is synced with the data, except for the pos/size
        properties.
        """
        if index in self.views:
            return self.views[index]

        dirty_views = self.dirty_views
        viewclass = self.get_viewclass(index)
        if viewclass is None:
            return
        rv = self.recycleview
        stale = False
        view = None

        if viewclass in dirty_views:
            dirty_class = dirty_views[viewclass]
            if index in dirty_class:
                # we found ourself in the dirty list, no need to update data!
                view = dirty_class.pop(index)
            elif _cached_views[viewclass]:
                # global cache has this class, update data
                view, stale = _cached_views[viewclass].pop(), True
            elif dirty_class:
                # random any dirty view element - update data
                view, stale = dirty_class.popitem()[1], True
        elif _cached_views[viewclass]:
            # global cache has this class, update data
            view, stale = _cached_views[viewclass].pop(), True

        if view is None:
            # create a fresh one
            view = self.create_view(index, viewclass)

        if stale is True:
            item = self[index]
            if viewclass not in _view_base_cache:
                _view_base_cache[viewclass] = isinstance(view,
                                                         RecycleViewMixin)

            if _view_base_cache[viewclass]:
                view.refresh_view_attrs(rv, item)
            else:
                for key, value in item.items():
                    setattr(view, key, value)

        self.views[index] = view
        return view 
開發者ID:kivy-garden,項目名稱:garden.recycleview,代碼行數:52,代碼來源:recycleview.py


注:本文中的kivy.properties方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。