# eric4.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
key | Public method generating the key for this item.

### Static Methods

None

#### ArrayElementVarItem (Constructor)

ArrayElementVarItem(parent, dvar, dvalue, dtype)

Constructor

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

#### ArrayElementVarItem.key

key(column)

Public method generating the key for this item.

column
  the column to sort on (integer)

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
key | Public method generating the key for this item.

### Static Methods

None

#### SpecialArrayElementVarItem (Constructor)

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

Constructor

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

#### SpecialArrayElementVarItem.key

key(column)

Public method generating the key for this item.

column
  the column to sort on (integer)

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, scope)

Constructor

parent
  parent of this item
dvar
  variable name (string or QString)
dvalue
  value string (string or QString)
dtype
  type string (string or QString)
frmnr
  frame number (0 is the current frame) (int)
scope
  flag indicating global (1) or local (0) 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

None

### Class Methods

None

### Methods

VariableItem | Constructor.
__lt__ | Public method to check, if the item is less than the other one.
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.
getValue | Public method to return the value of the item.
key | Public method generating the key for this item.

### Static Methods

None

#### VariableItem (Constructor)

VariableItem(parent, dvar, dvalue, dtype)

Constructor.

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

#### VariableItem.__lt__

__lt__(other)

Public method to check, if the item is less than the other one.

other
  reference to item to compare against (QTreeWidgetItem)

Returns:
  true, if this item is less than other (boolean)

#### 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 (QVariant)

#### 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.getValue

getValue()

Public method to return the value of the item.

Returns:
  value of the item (QString)

#### VariableItem.key

key(column)

Public method generating the key for this item.

column
  the column to sort on (integer)

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.
__resort | Private method to resort the tree.
__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.
__unicode | Private method to convert a string to unicode.
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(parent=None, scope=1)

Constructor

parent
  the parent (QWidget)
scope
  flag indicating global (1) or local (0) variables

#### 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 or QStrings)
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 or QString)
dvalue
  value string (string or QString)
dtype
  type string (string or QString)
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 or QString)

#### VariablesViewer.__resort

__resort()

Private method to resort the tree.

#### 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.__unicode

__unicode(s)

Private method to convert a string to unicode.

s
  the string to be converted (string)

Returns:
  unicode representation of s (unicode object)

#### 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