Skip to content

Commit

Permalink
Object Explorer: Expand object one level
Browse files Browse the repository at this point in the history
  • Loading branch information
dalthviz committed Mar 17, 2019
1 parent a193c24 commit c93a870
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion spyder/plugins/variableexplorer/widgets/collectionseditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,8 @@ def createEditor(self, parent, option, index):
return editor
# CollectionsEditor for an arbitrary Python object
else:
editor = ObjectBrowser({_('Object'): value}, parent=parent)
editor = ObjectBrowser({_('Object'): value}, expanded=True,
parent=parent)
self.create_dialog(editor, dict(model=index.model(),
editor=editor,
key=key, readonly=readonly))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class ObjectBrowser(QDialog):
def __init__(self,
obj,
name='',
expanded=False,
parent=None,
attribute_columns=DEFAULT_ATTR_COLS,
attribute_details=DEFAULT_ATTR_DETAILS,
Expand Down Expand Up @@ -97,8 +98,8 @@ def __init__(self,
refresh_rate=refresh_rate,
show_callable_attributes=show_callable_attributes,
show_special_attributes=show_special_attributes)

self._tree_model = TreeModel(obj, name, attr_cols=self._attr_cols)
self._tree_model = TreeModel(obj, obj_name=name,
attr_cols=self._attr_cols)

self._proxy_tree_model = TreeProxyModel(
show_callable_attributes=show_callable_attributes,
Expand Down Expand Up @@ -132,7 +133,7 @@ def __init__(self,
# Select first row so that a hidden root node will not be selected.
first_row_index = self._proxy_tree_model.firstItemIndex()
self.obj_tree.setCurrentIndex(first_row_index)
if self._tree_model.inspectedNodeIsVisible:
if self._tree_model.inspectedNodeIsVisible or expanded:
self.obj_tree.expand(first_row_index)

def refresh(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def __init__(self,
self._inspected_node_is_visible = None
self._inspected_item = None
self._root_item = None
self.populateTree(obj, obj_name)
self.populateTree(obj, obj_name=obj_name)

@property
def inspectedNodeIsVisible(self):
Expand Down Expand Up @@ -334,7 +334,6 @@ def _fetchObjectChildren(self, obj, obj_path):
def populateTree(self, obj, obj_name='', inspected_node_is_visible=None):
"""Fills the tree using a python object. Sets the rootItem."""
logger.debug("populateTree with object id = 0x{:x}".format(id(obj)))

if inspected_node_is_visible is None:
inspected_node_is_visible = (obj_name != '')
self._inspected_node_is_visible = inspected_node_is_visible
Expand Down

0 comments on commit c93a870

Please sign in to comment.