本文整理汇总了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
示例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)
示例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)
示例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()
示例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
示例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())
示例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