Skip to content

Commit

Permalink
more pyviz porting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gjcarneiro committed Aug 15, 2018
1 parent 909b02f commit a949de4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
13 changes: 7 additions & 6 deletions src/visualizer/visualizer/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1527,24 +1527,25 @@ def start(self):


def on_root_button_press_event(self, view, target, event):
if event.button == 1:
if event.button.button == 1:
self.select_node(None)
return True

def on_node_button_press_event(self, view, target, event, node):
if event.button == 1:
button = event.button.button
if button == 1:
self.select_node(node)
return True
elif event.button == 3:
elif button == 3:
self.popup_node_menu(node, event)
return True
elif event.button == 2:
elif button == 2:
self.begin_node_drag(node)
return True
return False

def on_node_button_release_event(self, view, target, event, node):
if event.button == 2:
if event.button.button == 2:
self.end_node_drag(node)
return True
return False
Expand Down Expand Up @@ -1606,7 +1607,7 @@ def end_node_drag(self, node):
def popup_node_menu(self, node, event):
menu = Gtk.Menu()
self.emit("populate-node-menu", node, menu)
menu.popup(None, None, None, event.button, event.time)
menu.popup(None, None, None, None, event.button.button, event.time)

def _update_ipython_selected_node(self):
# If we are running under ipython -gthread, make this new
Expand Down
20 changes: 10 additions & 10 deletions src/visualizer/visualizer/plugins/interface_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class StatisticsCollector(object):

## NetDevStats class
class NetDevStats(object):
## @var __slots__
## @var __slots__
# class members
__slots__ = ['rxPackets', 'rxBytes', 'txPackets', 'txBytes',
'rxPacketRate', 'rxBitRate', 'txPacketRate', 'txBitRate']
Expand Down Expand Up @@ -61,7 +61,7 @@ def get_interface_statistics(self, nodeId):
raw_stats_list = self.node_statistics[nodeId]
except KeyError:
return []

if len(raw_stats_list) < NODE_STATISTICS_MEMORY:
return []
assert len(raw_stats_list) == NODE_STATISTICS_MEMORY
Expand All @@ -84,7 +84,7 @@ def get_interface_statistics(self, nodeId):
outStat.txBytes = stats.transmittedBytes
outStat.rxPackets = stats.receivedPackets
outStat.rxBytes = stats.receivedBytes

outStat.txPacketRate = (stats.transmittedPackets - tx_packets1[iface])/k
outStat.rxPacketRate = (stats.receivedPackets - rx_packets1[iface])/k
outStat.txBitRate = (stats.transmittedBytes - tx_bytes1[iface])*8/k
Expand Down Expand Up @@ -132,10 +132,10 @@ def __init__(self, visualizer, node_index, statistics_collector):
"""
InformationWindow.__init__(self)
self.win = Gtk.Dialog(parent=visualizer.window,
flags=Gtk.DialogFlags.DESTROY_WITH_PARENT|Gtk.DialogFlags.NO_SEPARATOR,
flags=Gtk.DialogFlags.DESTROY_WITH_PARENT,
buttons=(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE))
self.win.connect("response", self._response_cb)
self.win.set_title("Statistics for node %i" % node_index)
self.win.set_title("Statistics for node %i" % node_index)
self.visualizer = visualizer
self.statistics_collector = statistics_collector
self.node_index = node_index
Expand All @@ -146,11 +146,11 @@ def __init__(self, visualizer, node_index, statistics_collector):
treeview = Gtk.TreeView(self.table_model)
treeview.show()
self.win.vbox.add(treeview)

def add_column(descr, colid):
column = Gtk.TreeViewColumn(descr, Gtk.CellRendererText(), text=colid)
treeview.append_column(column)

add_column("Interface", self.COLUMN_INTERFACE)

add_column("Tx Packets", self.COLUMN_TX_PACKETS)
Expand All @@ -176,7 +176,7 @@ def _response_cb(self, win, response):
"""
self.win.destroy()
self.visualizer.remove_information_window(self)

def update(self):
"""!
Update function.
Expand All @@ -199,7 +199,7 @@ def update(self):
self.COLUMN_TX_BYTES, str(stats.txBytes),
self.COLUMN_TX_PACKET_RATE, str(stats.txPacketRate),
self.COLUMN_TX_BIT_RATE, str(stats.txBitRate),

self.COLUMN_RX_PACKETS, str(stats.rxPackets),
self.COLUMN_RX_BYTES, str(stats.rxBytes),
self.COLUMN_RX_PACKET_RATE, str(stats.rxPacketRate),
Expand All @@ -208,7 +208,7 @@ def update(self):


def populate_node_menu(viz, node, menu, statistics_collector):

menu_item = Gtk.MenuItem("Show Interface Statistics")
menu_item.show()

Expand Down
8 changes: 4 additions & 4 deletions src/visualizer/visualizer/plugins/ipv4_routing_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ def __init__(self, visualizer, node_index):
"""
InformationWindow.__init__(self)
self.win = Gtk.Dialog(parent=visualizer.window,
flags=Gtk.DialogFlags.DESTROY_WITH_PARENT|Gtk.DialogFlags.NO_SEPARATOR,
flags=Gtk.DialogFlags.DESTROY_WITH_PARENT,
buttons=(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE))
self.win.connect("response", self._response_cb)
self.win.set_title("IPv4 routing table for node %i" % node_index)
self.win.set_title("IPv4 routing table for node %i" % node_index)
self.visualizer = visualizer
self.node_index = node_index

Expand All @@ -52,7 +52,7 @@ def __init__(self, visualizer, node_index):
sw.add(treeview)
self.win.vbox.add(sw)
self.win.set_default_size(600, 300)

# Dest.
column = Gtk.TreeViewColumn('Destination', Gtk.CellRendererText(),
text=self.COLUMN_DESTINATION)
Expand Down Expand Up @@ -91,7 +91,7 @@ def _response_cb(self, win, response):
"""
self.win.destroy()
self.visualizer.remove_information_window(self)

def update(self):
"""!
Update function
Expand Down

0 comments on commit a949de4

Please sign in to comment.