Python pango.ALIGN_CENTER Examples
The following are 22
code examples of pango.ALIGN_CENTER().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pango
, or try the search function
.
Example #1
Source File: core.py From IEEE-802.11ah-ns-3 with GNU General Public License v2.0 | 5 votes |
def _update_appearance(self): """Update the node aspect to reflect the selected/highlighted state""" size = transform_distance_simulation_to_canvas(self._size) if self.svg_item is not None: alpha = 0x80 else: alpha = 0xff fill_color_rgba = (self._color & 0xffffff00) | alpha self.canvas_item.set_properties(radius_x=size, radius_y=size, fill_color_rgba=fill_color_rgba) if self._selected: line_width = size*.3 else: line_width = size*.15 if self.highlighted: stroke_color = 'yellow' else: stroke_color = 'black' self.canvas_item.set_properties(line_width=line_width, stroke_color=stroke_color) if self._label is not None: if self._label_canvas_item is None: self._label_canvas_item = goocanvas.Text(visibility_threshold=0.5, font="Sans Serif 10", fill_color_rgba=0x808080ff, alignment=pango.ALIGN_CENTER, anchor=gtk.ANCHOR_N, parent=self.visualizer.canvas.get_root_item(), pointer_events=0) self._label_canvas_item.lower(None) self._label_canvas_item.set_properties(visibility=goocanvas.ITEM_VISIBLE_ABOVE_THRESHOLD, text=self._label) self._update_position()
Example #2
Source File: core.py From Tocino with GNU General Public License v2.0 | 5 votes |
def _update_appearance(self): """Update the node aspect to reflect the selected/highlighted state""" size = transform_distance_simulation_to_canvas(self._size) if self.svg_item is not None: alpha = 0x80 else: alpha = 0xff fill_color_rgba = (self._color & 0xffffff00) | alpha self.canvas_item.set_properties(radius_x=size, radius_y=size, fill_color_rgba=fill_color_rgba) if self._selected: line_width = size*.3 else: line_width = size*.15 if self.highlighted: stroke_color = 'yellow' else: stroke_color = 'black' self.canvas_item.set_properties(line_width=line_width, stroke_color=stroke_color) if self._label is not None: if self._label_canvas_item is None: self._label_canvas_item = goocanvas.Text(visibility_threshold=0.5, font="Sans Serif 10", fill_color_rgba=0x808080ff, alignment=pango.ALIGN_CENTER, anchor=gtk.ANCHOR_N, parent=self.visualizer.canvas.get_root_item(), pointer_events=0) self._label_canvas_item.lower(None) self._label_canvas_item.set_properties(visibility=goocanvas.ITEM_VISIBLE_ABOVE_THRESHOLD, text=self._label) self._update_position()
Example #3
Source File: core.py From ns3-load-balance with GNU General Public License v2.0 | 5 votes |
def _update_appearance(self): """Update the node aspect to reflect the selected/highlighted state""" size = transform_distance_simulation_to_canvas(self._size) if self.svg_item is not None: alpha = 0x80 else: alpha = 0xff fill_color_rgba = (self._color & 0xffffff00) | alpha self.canvas_item.set_properties(radius_x=size, radius_y=size, fill_color_rgba=fill_color_rgba) if self._selected: line_width = size*.3 else: line_width = size*.15 if self.highlighted: stroke_color = 'yellow' else: stroke_color = 'black' self.canvas_item.set_properties(line_width=line_width, stroke_color=stroke_color) if self._label is not None: if self._label_canvas_item is None: self._label_canvas_item = goocanvas.Text(visibility_threshold=0.5, font="Sans Serif 10", fill_color_rgba=0x808080ff, alignment=pango.ALIGN_CENTER, anchor=gtk.ANCHOR_N, parent=self.visualizer.canvas.get_root_item(), pointer_events=0) self._label_canvas_item.lower(None) self._label_canvas_item.set_properties(visibility=goocanvas.ITEM_VISIBLE_ABOVE_THRESHOLD, text=self._label) self._update_position()
Example #4
Source File: core.py From 802.11ah-ns3 with GNU General Public License v2.0 | 5 votes |
def _update_appearance(self): """Update the node aspect to reflect the selected/highlighted state""" size = transform_distance_simulation_to_canvas(self._size) if self.svg_item is not None: alpha = 0x80 else: alpha = 0xff fill_color_rgba = (self._color & 0xffffff00) | alpha self.canvas_item.set_properties(radius_x=size, radius_y=size, fill_color_rgba=fill_color_rgba) if self._selected: line_width = size*.3 else: line_width = size*.15 if self.highlighted: stroke_color = 'yellow' else: stroke_color = 'black' self.canvas_item.set_properties(line_width=line_width, stroke_color=stroke_color) if self._label is not None: if self._label_canvas_item is None: self._label_canvas_item = goocanvas.Text(visibility_threshold=0.5, font="Sans Serif 10", fill_color_rgba=0x808080ff, alignment=pango.ALIGN_CENTER, anchor=gtk.ANCHOR_N, parent=self.visualizer.canvas.get_root_item(), pointer_events=0) self._label_canvas_item.lower(None) self._label_canvas_item.set_properties(visibility=goocanvas.ITEM_VISIBLE_ABOVE_THRESHOLD, text=self._label) self._update_position()
Example #5
Source File: core.py From ns3-802.11ad with GNU General Public License v2.0 | 5 votes |
def _update_appearance(self): """! Update the node aspect to reflect the selected/highlighted state @param self: class object. @return none """ size = transform_distance_simulation_to_canvas(self._size) if self.svg_item is not None: alpha = 0x80 else: alpha = 0xff fill_color_rgba = (self._color & 0xffffff00) | alpha self.canvas_item.set_properties(radius_x=size, radius_y=size, fill_color_rgba=fill_color_rgba) if self._selected: line_width = size*.3 else: line_width = size*.15 if self.highlighted: stroke_color = 'yellow' else: stroke_color = 'black' self.canvas_item.set_properties(line_width=line_width, stroke_color=stroke_color) if self._label is not None: if self._label_canvas_item is None: self._label_canvas_item = goocanvas.Text(visibility_threshold=0.5, font="Sans Serif 10", fill_color_rgba=0x808080ff, alignment=pango.ALIGN_CENTER, anchor=gtk.ANCHOR_N, parent=self.visualizer.canvas.get_root_item(), pointer_events=0) self._label_canvas_item.lower(None) self._label_canvas_item.set_properties(visibility=goocanvas.ITEM_VISIBLE_ABOVE_THRESHOLD, text=self._label) self._update_position()
Example #6
Source File: core.py From ns3-rdma with GNU General Public License v2.0 | 5 votes |
def _update_appearance(self): """Update the node aspect to reflect the selected/highlighted state""" size = transform_distance_simulation_to_canvas(self._size) if self.svg_item is not None: alpha = 0x80 else: alpha = 0xff fill_color_rgba = (self._color & 0xffffff00) | alpha self.canvas_item.set_properties(radius_x=size, radius_y=size, fill_color_rgba=fill_color_rgba) if self._selected: line_width = size*.3 else: line_width = size*.15 if self.highlighted: stroke_color = 'yellow' else: stroke_color = 'black' self.canvas_item.set_properties(line_width=line_width, stroke_color=stroke_color) if self._label is not None: if self._label_canvas_item is None: self._label_canvas_item = goocanvas.Text(visibility_threshold=0.5, font="Sans Serif 10", fill_color_rgba=0x808080ff, alignment=pango.ALIGN_CENTER, anchor=gtk.ANCHOR_N, parent=self.visualizer.canvas.get_root_item(), pointer_events=0) self._label_canvas_item.lower(None) self._label_canvas_item.set_properties(visibility=goocanvas.ITEM_VISIBLE_ABOVE_THRESHOLD, text=self._label) self._update_position()
Example #7
Source File: core.py From royal-chaos with MIT License | 5 votes |
def _update_appearance(self): """! Update the node aspect to reflect the selected/highlighted state @param self: class object. @return none """ size = transform_distance_simulation_to_canvas(self._size) if self.svg_item is not None: alpha = 0x80 else: alpha = 0xff fill_color_rgba = (self._color & 0xffffff00) | alpha self.canvas_item.set_properties(radius_x=size, radius_y=size, fill_color_rgba=fill_color_rgba) if self._selected: line_width = size*.3 else: line_width = size*.15 if self.highlighted: stroke_color = 'yellow' else: stroke_color = 'black' self.canvas_item.set_properties(line_width=line_width, stroke_color=stroke_color) if self._label is not None: if self._label_canvas_item is None: self._label_canvas_item = goocanvas.Text(visibility_threshold=0.5, font="Sans Serif 10", fill_color_rgba=0x808080ff, alignment=pango.ALIGN_CENTER, anchor=gtk.ANCHOR_N, parent=self.visualizer.canvas.get_root_item(), pointer_events=0) self._label_canvas_item.lower(None) self._label_canvas_item.set_properties(visibility=goocanvas.ITEM_VISIBLE_ABOVE_THRESHOLD, text=self._label) self._update_position()
Example #8
Source File: core.py From ntu-dsi-dcn with GNU General Public License v2.0 | 5 votes |
def _update_appearance(self): """Update the node aspect to reflect the selected/highlighted state""" size = transform_distance_simulation_to_canvas(self._size) if self.svg_item is not None: alpha = 0x80 else: alpha = 0xff fill_color_rgba = (self._color & 0xffffff00) | alpha self.canvas_item.set_properties(radius_x=size, radius_y=size, fill_color_rgba=fill_color_rgba) if self._selected: line_width = size*.3 else: line_width = size*.15 if self.highlighted: stroke_color = 'yellow' else: stroke_color = 'black' self.canvas_item.set_properties(line_width=line_width, stroke_color=stroke_color) if self._label is not None: if self._label_canvas_item is None: self._label_canvas_item = goocanvas.Text(visibility_threshold=0.5, font="Sans Serif 10", fill_color_rgba=0x808080ff, alignment=pango.ALIGN_CENTER, anchor=gtk.ANCHOR_N, parent=self.visualizer.canvas.get_root_item(), pointer_events=0) self._label_canvas_item.lower(None) self._label_canvas_item.set_properties(visibility=goocanvas.ITEM_VISIBLE_ABOVE_THRESHOLD, text=self._label) self._update_position()
Example #9
Source File: core.py From ns-3-dev-git with GNU General Public License v2.0 | 5 votes |
def _update_appearance(self): """Update the node aspect to reflect the selected/highlighted state""" size = transform_distance_simulation_to_canvas(self._size) if self.svg_item is not None: alpha = 0x80 else: alpha = 0xff fill_color_rgba = (self._color & 0xffffff00) | alpha self.canvas_item.set_properties(radius_x=size, radius_y=size, fill_color_rgba=fill_color_rgba) if self._selected: line_width = size*.3 else: line_width = size*.15 if self.highlighted: stroke_color = 'yellow' else: stroke_color = 'black' self.canvas_item.set_properties(line_width=line_width, stroke_color=stroke_color) if self._label is not None: if self._label_canvas_item is None: self._label_canvas_item = goocanvas.Text(visibility_threshold=0.5, font="Sans Serif 10", fill_color_rgba=0x808080ff, alignment=pango.ALIGN_CENTER, anchor=gtk.ANCHOR_N, parent=self.visualizer.canvas.get_root_item(), pointer_events=0) self._label_canvas_item.lower(None) self._label_canvas_item.set_properties(visibility=goocanvas.ITEM_VISIBLE_ABOVE_THRESHOLD, text=self._label) self._update_position()
Example #10
Source File: core.py From ns3-ecn-sharp with GNU General Public License v2.0 | 5 votes |
def _update_appearance(self): """Update the node aspect to reflect the selected/highlighted state""" size = transform_distance_simulation_to_canvas(self._size) if self.svg_item is not None: alpha = 0x80 else: alpha = 0xff fill_color_rgba = (self._color & 0xffffff00) | alpha self.canvas_item.set_properties(radius_x=size, radius_y=size, fill_color_rgba=fill_color_rgba) if self._selected: line_width = size*.3 else: line_width = size*.15 if self.highlighted: stroke_color = 'yellow' else: stroke_color = 'black' self.canvas_item.set_properties(line_width=line_width, stroke_color=stroke_color) if self._label is not None: if self._label_canvas_item is None: self._label_canvas_item = goocanvas.Text(visibility_threshold=0.5, font="Sans Serif 10", fill_color_rgba=0x808080ff, alignment=pango.ALIGN_CENTER, anchor=gtk.ANCHOR_N, parent=self.visualizer.canvas.get_root_item(), pointer_events=0) self._label_canvas_item.lower(None) self._label_canvas_item.set_properties(visibility=goocanvas.ITEM_VISIBLE_ABOVE_THRESHOLD, text=self._label) self._update_position()
Example #11
Source File: core.py From CRE-NS3 with GNU General Public License v2.0 | 5 votes |
def _update_appearance(self): """Update the node aspect to reflect the selected/highlighted state""" size = transform_distance_simulation_to_canvas(self._size) if self.svg_item is not None: alpha = 0x80 else: alpha = 0xff fill_color_rgba = (self._color & 0xffffff00) | alpha self.canvas_item.set_properties(radius_x=size, radius_y=size, fill_color_rgba=fill_color_rgba) if self._selected: line_width = size*.3 else: line_width = size*.15 if self.highlighted: stroke_color = 'yellow' else: stroke_color = 'black' self.canvas_item.set_properties(line_width=line_width, stroke_color=stroke_color) if self._label is not None: if self._label_canvas_item is None: self._label_canvas_item = goocanvas.Text(visibility_threshold=0.5, font="Sans Serif 10", fill_color_rgba=0x808080ff, alignment=pango.ALIGN_CENTER, anchor=gtk.ANCHOR_N, parent=self.visualizer.canvas.get_root_item(), pointer_events=0) self._label_canvas_item.lower(None) self._label_canvas_item.set_properties(visibility=goocanvas.ITEM_VISIBLE_ABOVE_THRESHOLD, text=self._label) self._update_position()
Example #12
Source File: core.py From royal-chaos with MIT License | 4 votes |
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
Example #13
Source File: core.py From Tocino with GNU General Public License v2.0 | 4 votes |
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
Example #14
Source File: core.py From ns3-802.11ad with GNU General Public License v2.0 | 4 votes |
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
Example #15
Source File: core.py From ns3-ecn-sharp with GNU General Public License v2.0 | 4 votes |
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
Example #16
Source File: core.py From CRE-NS3 with GNU General Public License v2.0 | 4 votes |
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
Example #17
Source File: core.py From ns-3-dev-git with GNU General Public License v2.0 | 4 votes |
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
Example #18
Source File: core.py From ns3-rdma with GNU General Public License v2.0 | 4 votes |
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
Example #19
Source File: core.py From 802.11ah-ns3 with GNU General Public License v2.0 | 4 votes |
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
Example #20
Source File: core.py From ns3-load-balance with GNU General Public License v2.0 | 4 votes |
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
Example #21
Source File: core.py From IEEE-802.11ah-ns-3 with GNU General Public License v2.0 | 4 votes |
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
Example #22
Source File: core.py From ntu-dsi-dcn with GNU General Public License v2.0 | 4 votes |
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