Skip to content

Commit

Permalink
minor fixes for ds_tree
Browse files Browse the repository at this point in the history
to account for the changes in psyplot/psyplot-gui#16
  • Loading branch information
Chilipp committed Jun 15, 2020
1 parent b6027e5 commit 9d68422
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions psy_view/ds_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,24 +336,26 @@ def setup_variable_buttons(self, ncols=4):
self.variable_layout.addWidget(btn, i // ncols, i % ncols)

def load_variable_desc(self, item):
# if we are not at the lowest level or the item has already label, pass
if item.child(0).childCount() or self.ds_tree.itemWidget(
item.child(0), 0):
parent = item.parent()

tree = self.ds_tree

if parent is tree or parent is None or not (
DatasetTree.is_variable(item) or DatasetTree.is_coord(item)):
return

if tree.isColumnHidden(1):
tree.showColumn(1)
tree.resizeColumnToContents(0)

top = item
while top.parent() and top.parent() is not self.ds_tree:
while top.parent() and top.parent() is not self:
top = top.parent()
ds = top.ds()
if ds is None:
return
widget = QtWidgets.QScrollArea()
label = QtWidgets.QLabel(
'<pre>' + escape_html(str(ds.variables[item.text(0)])) + '</pre>')
label.setTextFormat(Qt.RichText)
widget.setWidget(label)
self.ds_tree.setItemWidget(item.child(0), 0, widget)
item.child(0).setFirstColumnSpanned(True)
desc = escape_html(str(ds.variables[item.text(0)]))
item.setToolTip(0, '<pre>' + desc + '</pre>')

def clear_table(self):
self.dimension_table.clear()
Expand Down Expand Up @@ -962,6 +964,15 @@ def refresh(self):

table.resizeColumnsToContents()

# update plots items
for ds_item in self.ds_items:
for item in map(ds_item.child, range(ds_item.childCount())):
for child in map(item.child, range(item.childCount())):
if DatasetTree.is_variable(child):
plots_item = ds_item.get_plots_item(child)
ds_item.refresh_plots_item(
plots_item, child.text(0), self._sp, self.sp)

# update animation checkbox
dims_to_animate = get_dims_to_iterate(data)

Expand Down

0 comments on commit 9d68422

Please sign in to comment.