本文整理汇总了Python中goocanvas.Points方法的典型用法代码示例。如果您正苦于以下问题:Python goocanvas.Points方法的具体用法?Python goocanvas.Points怎么用?Python goocanvas.Points使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类goocanvas
的用法示例。
在下文中一共展示了goocanvas.Points方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_points
# 需要导入模块: import goocanvas [as 别名]
# 或者: from goocanvas import Points [as 别名]
def update_points(self):
if self.node2 is None:
return
pos1_x, pos1_y = self.node1.get_position()
pos2_x, pos2_y = self.node2.get_position()
points = goocanvas.Points([(pos1_x, pos1_y), (pos2_x, pos2_y)])
self.visible_line.set_property("points", points)
self.invisible_line.set_property("points", points)
示例2: update_points
# 需要导入模块: import goocanvas [as 别名]
# 或者: from goocanvas import Points [as 别名]
def update_points(self):
"""! Update points function.
@param self The object pointer.
@return none
"""
if self.node2 is None:
return
pos1_x, pos1_y = self.node1.get_position()
pos2_x, pos2_y = self.node2.get_position()
points = goocanvas.Points([(pos1_x, pos1_y), (pos2_x, pos2_y)])
self.visible_line.set_property("points", points)
self.invisible_line.set_property("points", points)
示例3: _update_drops_view
# 需要导入模块: import goocanvas [as 别名]
# 或者: from goocanvas import Points [as 别名]
def _update_drops_view(self):
drops_average = {}
for drop_set in self._last_drops:
for drop in drop_set:
key = drop.transmitter.GetId()
drop_bytes, count = drops_average.get(key, (0, 0))
drop_bytes += drop.bytes
count += 1
drops_average[key] = drop_bytes, count
old_arrows = self._drop_arrows
for arrow, label in old_arrows:
arrow.set_property("visibility", goocanvas.ITEM_HIDDEN)
label.set_property("visibility", goocanvas.ITEM_HIDDEN)
new_arrows = []
# get the coordinates for the edge of screen
vadjustment = self._scrolled_window.get_vadjustment()
bottom_y = vadjustment.value + vadjustment.page_size
dummy, edge_y = self.canvas.convert_from_pixels(0, bottom_y)
k = self.node_size_adjustment.value/5
for transmitter_id, (drop_bytes, drop_count) in drops_average.iteritems():
transmitter = self.get_node(transmitter_id)
try:
arrow, label = old_arrows.pop()
except IndexError:
arrow = goocanvas.Polyline(line_width=2.0, stroke_color_rgba=0xC00000C0, close_path=False, end_arrow=True)
arrow.props.pointer_events = 0
arrow.set_property("parent", self.canvas.get_root_item())
arrow.raise_(None)
label = goocanvas.Text()#, fill_color_rgba=0x00C000C0)
label.props.pointer_events = 0
label.set_property("parent", self.canvas.get_root_item())
label.raise_(None)
arrow.set_property("visibility", goocanvas.ITEM_VISIBLE)
arrow.set_property("line-width", max(0.1, math.log(float(drop_bytes)/drop_count/self.sample_period)*k))
pos1_x, pos1_y = transmitter.get_position()
pos2_x, pos2_y = pos1_x, edge_y
points = goocanvas.Points([(pos1_x, pos1_y), (pos2_x, pos2_y)])
arrow.set_property("points", points)
label.set_properties(visibility=goocanvas.ITEM_VISIBLE_ABOVE_THRESHOLD,
visibility_threshold=0.5,
font=("Sans Serif %i" % int(1+BITRATE_FONT_SIZE*k)),
text=("%.2f kbit/s" % (float(drop_bytes*8)/1e3/drop_count/self.sample_period,)),
alignment=pango.ALIGN_CENTER,
x=(pos1_x + pos2_x)/2,
y=(pos1_y + pos2_y)/2)
new_arrows.append((arrow, label))
self._drop_arrows = new_arrows + old_arrows