本文整理汇总了Python中networks.network.Network.attached_links方法的典型用法代码示例。如果您正苦于以下问题:Python Network.attached_links方法的具体用法?Python Network.attached_links怎么用?Python Network.attached_links使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类networks.network.Network
的用法示例。
在下文中一共展示了Network.attached_links方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MainNetworkView
# 需要导入模块: from networks.network import Network [as 别名]
# 或者: from networks.network.Network import attached_links [as 别名]
class MainNetworkView(GeographicalView, NetworkView):
subtype = 'network'
menu_type = 'network'
def __init__(self, controller):
self.network = Network(self)
super().__init__(controller)
# given a graphical node, retrieves all attached graphical links
def attached_glinks(self, gnode):
for link in self.network.attached_links(gnode.node):
if 'vc' in link.subtype:
continue
yield link.glink[self]
def draw_objects(self, *objects):
for obj in objects:
if obj.class_type == 'node' and self not in obj.gnode:
GraphicalNetworkNode(self, obj)
if obj.class_type == 'link' and self not in obj.glink:
if 'vc' in obj.subtype:
continue
self.draw_objects(obj.source, obj.destination)
GraphicalLink(self, obj)
def dropEvent(self, event):
pos = self.mapToScene(event.pos())
geo_pos = self.world_map.to_geographical_coordinates(pos.x(), pos.y())
if event.mimeData().hasFormat('application/x-dnditemdata'):
new_gnode = GraphicalNetworkNode(self)
new_gnode.setPos(pos)
# update the nodes coordinates at creation
new_gnode.node.longitude, new_gnode.node.latitude = geo_pos