Skip to content

Commit

Permalink
some dynamic resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
oroulet committed Sep 28, 2015
1 parent d578fca commit 6fb84d3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ def __init__(self):
self.ui.disconnectButton.clicked.connect(self._disconnect)
self.ui.treeView.activated.connect(self._show_attrs_and_refs)
self.ui.treeView.clicked.connect(self._show_attrs_and_refs)
self.ui.treeView.expanded.connect(self._fit)

def _fit(self, idx):
self.ui.treeView.resizeColumnToContents(0)

def _show_attrs_and_refs(self, idx):
print("Activated", idx)
Expand All @@ -46,19 +50,26 @@ def _show_attrs_and_refs(self, idx):
attrs = self.uaclient.get_all_node_attrs(node)
print("attrs : ", attrs)
self.attr_model.clear()
self.model.setHorizontalHeaderLabels(['Name', 'NodeId', 'NodeClass'])
for k, v in attrs.items():
self.attr_model.appendRow([QtGui.QStandardItem(k), QtGui.QStandardItem(str(v))])
self.ui.attrView.resizeColumnToContents(0)
self.ui.attrView.resizeColumnToContents(1)

def _connect(self):
self._disconnect()
uri = self.ui.addrLineEdit.text()
self.uaclient.connect(uri)
self.model.client = self.uaclient
self.model.add_item(self.uaclient.get_root_attrs())
self.ui.treeView.resizeColumnToContents(0)
self.ui.treeView.resizeColumnToContents(1)
self.ui.treeView.resizeColumnToContents(2)

def _disconnect(self):
self.uaclient.disconnect()
self.model.clear()
self.model.setHorizontalHeaderLabels(['Name', 'NodeId', 'NodeClass'])
self.model.client = None

def closeEvent(self, event):
Expand Down

0 comments on commit 6fb84d3

Please sign in to comment.