# eric6.Debugger.VariablesViewer

Module implementing the variables viewer widget.

### Global Attributes

None

### Classes

ArrayElementVarItem | Class implementing a VariableItem that represents an array element.
SpecialArrayElementVarItem | Class implementing a QTreeWidgetItem that represents a special array variable node.
SpecialVarItem | Class implementing a VariableItem that represents a special variable node.
VariableItem | Class implementing the data structure for variable items.
VariablesViewer | Class implementing the variables viewer widget.

### Functions

None

## ArrayElementVarItem

Class implementing a VariableItem that represents an array element.

### Derived from

VariableItem

### Class Attributes

None

### Class Methods

None

### Methods

ArrayElementVarItem | Constructor

### Static Methods

None

#### ArrayElementVarItem (Constructor)

ArrayElementVarItem(parent, dvar, dvalue, dtype)

Constructor

parent
  parent of this item
dvar
  variable name (string)
dvalue
  value string (string)
dtype
  type string (string)

Up

## SpecialArrayElementVarItem

Class implementing a QTreeWidgetItem that represents a special array variable node.

### Derived from

SpecialVarItem

### Class Attributes

None

### Class Methods

None

### Methods

SpecialArrayElementVarItem | Constructor

### Static Methods

None

#### SpecialArrayElementVarItem (Constructor)

SpecialArrayElementVarItem(parent, dvar, dvalue, dtype, frmnr, globalScope)

Constructor

parent
  parent of this item
dvar
  variable name (string)
dvalue
  value string (string)
dtype
  type string (string)
frmnr
  frame number (0 is the current frame) (int)
globalScope
  flag indicating global (True) or local (False) variables

Up

## SpecialVarItem

Class implementing a VariableItem that represents a special variable node.

These special variable nodes are generated for classes, lists, tuples and dictionaries.

### Derived from

VariableItem

### Class Attributes

None

### Class Methods

None

### Methods

SpecialVarItem | Constructor
expand | Public method to expand the item.

### Static Methods

None

#### SpecialVarItem (Constructor)

SpecialVarItem(parent, dvar, dvalue, dtype, frmnr, globalScope)

Constructor

parent
  parent of this item
dvar
  variable name (string)
dvalue
  value string (string)
dtype
  type string (string)
frmnr
  frame number (0 is the current frame) (int)
globalScope
  flag indicating global (True) or local (False) variables

#### SpecialVarItem.expand

expand()

Public method to expand the item.

Up

## VariableItem

Class implementing the data structure for variable items.

### Derived from

QTreeWidgetItem

### Class Attributes

Indicators
Type2Indicators

### Class Methods

extractId | Class method to extract the ID string from a variable text.
extractIndicators | Class method to extract the indicator string from a variable text.

### Methods

VariableItem | Constructor
_buildKey | Protected method to build the access key for the variable.
attachDummy | Public method to attach a dummy sub item to allow for lazy population.
collapse | Public method to collapse the item.
data | Public method to return the data for the requested role.
deleteChildren | Public method to delete all children (cleaning the subtree).
expand | Public method to expand the item.
getId | Public method to get the ID string.
getValue | Public method to return the value of the item.

### Static Methods

None

#### VariableItem.extractId (class method)

extractId(var)

Class method to extract the ID string from a variable text.

var (str)
  variable text

Returns:
  tuple containing the variable text without ID and the ID string

Return Type:
  tuple of two str

#### VariableItem.extractIndicators (class method)

extractIndicators(var)

Class method to extract the indicator string from a variable text.

var (str)
  variable text

Returns:
  tuple containing the variable text without indicators and the indicator string

Return Type:
  tuple of two str

#### VariableItem (Constructor)

VariableItem(parent, dvar, dvalue, dtype)

Constructor

parent
  reference to the parent item
dvar
  variable name (string)
dvalue
  value string (string)
dtype
  type string (string)

#### VariableItem._buildKey

_buildKey()

Protected method to build the access key for the variable.

Returns:
  access key

Return Type:
  str

#### VariableItem.attachDummy

attachDummy()

Public method to attach a dummy sub item to allow for lazy population.

#### VariableItem.collapse

collapse()

Public method to collapse the item.

Note: This is just a do nothing and should be overwritten.

#### VariableItem.data

data(column, role)

Public method to return the data for the requested role.

This implementation changes the original behavior in a way, that the display data is returned as the tooltip for column 1.

column
  column number (integer)
role
  data role (Qt.ItemDataRole)

Returns:
  requested data

#### VariableItem.deleteChildren

deleteChildren()

Public method to delete all children (cleaning the subtree).

#### VariableItem.expand

expand()

Public method to expand the item.

Note: This is just a do nothing and should be overwritten.

#### VariableItem.getId

getId()

Public method to get the ID string.

Returns:
  ID string

Return Type:
  str

#### VariableItem.getValue

getValue()

Public method to return the value of the item.

Returns:
  value of the item (string)

Up

## VariablesViewer

Class implementing the variables viewer widget.

This widget is used to display the variables of the program being debugged in a tree. Compound types will be shown with their main entry first. Once the subtree has been expanded, the individual entries will be shown. Double clicking an entry will popup a dialog showing the variables parameters in a more readable form. This is especially useful for lengthy strings.

This widget has two modes for displaying the global and the local variables.

### Derived from

QTreeWidget

### Class Attributes

None

### Class Methods

None

### Methods

VariablesViewer | Constructor
__addItem | Private method used to add an item to the list.
__buildTreePath | Private method to build up a path from the top to an item.
__configure | Private method to open the configuration dialog.
__createPopupMenus | Private method to generate the popup menus.
__expandItemSignal | Private slot to handle the expanded signal.
__findItem | Private method to search for an item.
__generateItem | Private method used to generate a VariableItem.
__getDispType | Private method used to get the display string for type vtype.
__refreshView | Private slot to refresh the view.
__resort | Private method to resort the tree.
__sectionClicked | Private method handling a click onto a header section.
__showContextMenu | Private slot to show the context menu.
__showDetails | Private slot to show details about the selected variable.
__showVariableDetails | Private method to show details about a variable.
collapseItem | Public slot to handle the collapsed signal.
expandItem | Public slot to handle the expanded signal.
handleResetUI | Public method to reset the VariablesViewer.
mouseDoubleClickEvent | Protected method of QAbstractItemView.
showVariable | Public method to show variables in a list.
showVariables | Public method to show variables in a list.

### Static Methods

None

#### VariablesViewer (Constructor)

VariablesViewer(viewer, globalScope, parent=None)

Constructor

viewer
  reference to the debug viewer object (DebugViewer)
globalScope
  flag indicating global (True) or local (False) variables
parent
  the parent (QWidget)

#### VariablesViewer.__addItem

__addItem(parent, vtype, var, value)

Private method used to add an item to the list.

If the item is of a type with subelements (i.e. list, dictionary, tuple), these subelements are added by calling this method recursively.

parent
  the parent of the item to be added (QTreeWidgetItem or None)
vtype
  the type of the item to be added (string)
var
  the variable name (string)
value
  the value string (string)

Returns:
  The item that was added to the listview (QTreeWidgetItem).

#### VariablesViewer.__buildTreePath

__buildTreePath(itm)

Private method to build up a path from the top to an item.

itm
  item to build the path for (QTreeWidgetItem)

Returns:
  list of names denoting the path from the top (list of strings)

#### VariablesViewer.__configure

__configure()

Private method to open the configuration dialog.

#### VariablesViewer.__createPopupMenus

__createPopupMenus()

Private method to generate the popup menus.

#### VariablesViewer.__expandItemSignal

__expandItemSignal(parentItem)

Private slot to handle the expanded signal.

parentItem
  reference to the item being expanded (QTreeWidgetItem)

#### VariablesViewer.__findItem

__findItem(slist, column, node=None)

Private method to search for an item.

It is used to find a specific item in column, that is a child of node. If node is None, a child of the QTreeWidget is searched.

slist
  searchlist (list of strings)
column
  index of column to search in (int)
node
  start point of the search

Returns:
  the found item or None

#### VariablesViewer.__generateItem

__generateItem(parent, dvar, dvalue, dtype, isSpecial=False)

Private method used to generate a VariableItem.

parent
  parent of the item to be generated
dvar
  variable name (string)
dvalue
  value string (string)
dtype
  type string (string)
isSpecial
  flag indicating that a special node should be generated (boolean)

Returns:
  The item that was generated (VariableItem).

#### VariablesViewer.__getDispType

__getDispType(vtype)

Private method used to get the display string for type vtype.

vtype
  the type, the display string should be looked up for (string)

Returns:
  displaystring (string)

#### VariablesViewer.__refreshView

__refreshView()

Private slot to refresh the view.

#### VariablesViewer.__resort

__resort(parent=None)

Private method to resort the tree.

parent (QTreeWidgetItem)
  reference to a parent item

#### VariablesViewer.__sectionClicked

__sectionClicked()

Private method handling a click onto a header section.

#### VariablesViewer.__showContextMenu

__showContextMenu(coord)

Private slot to show the context menu.

coord
  the position of the mouse pointer (QPoint)

#### VariablesViewer.__showDetails

__showDetails()

Private slot to show details about the selected variable.

#### VariablesViewer.__showVariableDetails

__showVariableDetails(itm)

Private method to show details about a variable.

itm
  reference to the variable item

#### VariablesViewer.collapseItem

collapseItem(parentItem)

Public slot to handle the collapsed signal.

parentItem
  reference to the item being collapsed (QTreeWidgetItem)

#### VariablesViewer.expandItem

expandItem(parentItem)

Public slot to handle the expanded signal.

parentItem
  reference to the item being expanded (QTreeWidgetItem)

#### VariablesViewer.handleResetUI

handleResetUI()

Public method to reset the VariablesViewer.

#### VariablesViewer.mouseDoubleClickEvent

mouseDoubleClickEvent(mouseEvent)

Protected method of QAbstractItemView.

Reimplemented to disable expanding/collapsing of items when double-clicking. Instead the double-clicked entry is opened.

mouseEvent
  the mouse event object (QMouseEvent)

#### VariablesViewer.showVariable

showVariable(vlist)

Public method to show variables in a list.

vlist
  the list of subitems to be displayed. The first element gives the path of the parent variable. Each other listentry is a tuple of three values.
  - the variable name (string)
  - the variables type (string)
  - the variables value (string)

#### VariablesViewer.showVariables

showVariables(vlist, frmnr)

Public method to show variables in a list.

vlist
  the list of variables to be displayed. Each listentry is a tuple of three values.
  - the variable name (string)
  - the variables type (string)
  - the variables value (string)
frmnr
  frame number (0 is the current frame) (int)

Up