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


Python goocanvas.Polyline方法代碼示例

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


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

示例1: __init__

# 需要導入模塊: import goocanvas [as 別名]
# 或者: from goocanvas import Polyline [as 別名]
def __init__(self, parent_canvas_item, sta, dev):
        self.node1 = sta
        self.dev = dev
        self.node2 = None # ap
        self.canvas_item = goocanvas.Group(parent=parent_canvas_item)
        self.invisible_line = goocanvas.Polyline(parent=self.canvas_item,
                                                 line_width=25.0,
                                                 visibility=goocanvas.ITEM_HIDDEN)
        self.visible_line = goocanvas.Polyline(parent=self.canvas_item,
                                              line_width=1.0,
                                              stroke_color_rgba=0xC00000FF,
                                              line_dash=goocanvas.LineDash([2.0, 2.0 ]))
        self.invisible_line.props.pointer_events = (goocanvas.EVENTS_STROKE_MASK
                                                    |goocanvas.EVENTS_FILL_MASK
                                                    |goocanvas.EVENTS_PAINTED_MASK)
        self.canvas_item.set_data("pyviz-object", self)
        self.canvas_item.lower(None)
        self.set_ap(None) 
開發者ID:ntu-dsi-dcn,項目名稱:ntu-dsi-dcn,代碼行數:20,代碼來源:wifi_intrastructure_link.py

示例2: __init__

# 需要導入模塊: import goocanvas [as 別名]
# 或者: from goocanvas import Polyline [as 別名]
def __init__(self, parent_canvas_item, sta, dev):
        """! Initialize function.
        @param self The object pointer.
        @param parent_canvas_item: parent canvas
        @param sta The STA node
        @param dev The dev
        """
        self.node1 = sta
        self.dev = dev
        self.node2 = None # ap
        self.canvas_item = goocanvas.Group(parent=parent_canvas_item)
        self.invisible_line = goocanvas.Polyline(parent=self.canvas_item,
                                                 line_width=25.0,
                                                 visibility=goocanvas.ITEM_HIDDEN)
        self.visible_line = goocanvas.Polyline(parent=self.canvas_item,
                                              line_width=1.0,
                                              stroke_color_rgba=0xC00000FF,
                                              line_dash=goocanvas.LineDash([2.0, 2.0 ]))
        self.invisible_line.props.pointer_events = (goocanvas.EVENTS_STROKE_MASK
                                                    |goocanvas.EVENTS_FILL_MASK
                                                    |goocanvas.EVENTS_PAINTED_MASK)
        self.canvas_item.set_data("pyviz-object", self)
        self.canvas_item.lower(None)
        self.set_ap(None) 
開發者ID:KTH,項目名稱:royal-chaos,代碼行數:26,代碼來源:wifi_intrastructure_link.py

示例3: _update_drops_view

# 需要導入模塊: import goocanvas [as 別名]
# 或者: from goocanvas import Polyline [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 
開發者ID:ntu-dsi-dcn,項目名稱:ntu-dsi-dcn,代碼行數:58,代碼來源:core.py


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