# eric7.UI.NumbersWidget

Module implementing a widget to show numbers in different formats.

### Global Attributes

None

### Classes

BinaryModel | Class implementing a model for entering binary numbers.
NumbersWidget | Class implementing a widget to show numbers in different formats.

### Functions

None

## BinaryModel

Class implementing a model for entering binary numbers.

### Derived from

QAbstractTableModel

### Class Attributes

None

### Class Methods

None

### Methods

BinaryModel | Constructor
columnCount | Public method to get the number of columns of the model.
data | Public method to get data from the model.
flags | Public method to get flags from the model.
getValue | Public slot to get the current value.
headerData | Public method to get header data from the model.
rowCount | Public method to get the number of rows of the model.
setBits | Public slot to set the number of bits.
setBitsAndValue | Public slot to set the number of bits and the value to show.
setData | Public method to set the data of a node cell.
setValue | Public slot to set the value to show.

### Static Methods

None

#### BinaryModel (Constructor)

BinaryModel(parent=None)

Constructor

parent
  reference to the parent widget (QWidget)

#### BinaryModel.columnCount

columnCount(parent)

Public method to get the number of columns of the model.

parent
  parent index (QModelIndex)

Return:
  number of columns (integer)

#### BinaryModel.data

data(index, role=Qt.ItemDataRole.DisplayRole)

Public method to get data from the model.

index
  index to get data for (QModelIndex)
role
  role of the data to retrieve (integer)

Return:
  requested data

#### BinaryModel.flags

flags(index)

Public method to get flags from the model.

index
  index to get flags for (QModelIndex)

Return:
  flags (Qt.ItemFlags)

#### BinaryModel.getValue

getValue()

Public slot to get the current value.

Return:
  current value of the model (integer)

#### BinaryModel.headerData

headerData(section, orientation, role=Qt.ItemDataRole.DisplayRole)

Public method to get header data from the model.

section
  section number (integer)
orientation
  orientation (Qt.Orientation)
role
  role of the data to retrieve (Qt.ItemDataRole)

Return:
  requested data

#### BinaryModel.rowCount

rowCount(parent)

Public method to get the number of rows of the model.

parent
  parent index (QModelIndex)

Return:
  number of columns (integer)

#### BinaryModel.setBits

setBits(bits)

Public slot to set the number of bits.

bits
  number of bits to show (integer)

#### BinaryModel.setBitsAndValue

setBitsAndValue(bits, value)

Public slot to set the number of bits and the value to show.

bits
  number of bits to show (integer)
value
  value to show (integer)

#### BinaryModel.setData

setData(index, value, role=Qt.ItemDataRole.EditRole)

Public method to set the data of a node cell.

index
  index of the node cell (QModelIndex)
value
  value to be set
role
  role of the data (integer)

Return:
  flag indicating success (boolean)

#### BinaryModel.setValue

setValue(value)

Public slot to set the value to show.

value
  value to show (integer)

Up

## NumbersWidget

Class implementing a widget to show numbers in different formats.

### Signals

insertNumber(str)
  emitted after the user has entered a number and selected the number format

### Derived from

QWidget, Ui_NumbersWidget

### Class Attributes

None

### Class Methods

None

### Methods

NumbersWidget | Constructor
__binModelDataChanged | Private slot to handle a change of the binary model value by the user.
__block | Private slot to block some signals.
__formatNumbers | Private method to format the various number inputs.
on_binEdit_textChanged | Private slot to handle input of a binary number.
on_binInButton_clicked | Private slot to retrieve a binary number from the current editor.
on_binOutButton_clicked | Private slot to send a binary number.
on_byteOrderButton_clicked | Private slot to swap the byte order.
on_decEdit_textChanged | Private slot to handle input of a decimal number.
on_decInButton_clicked | Private slot to retrieve a decimal number from the current editor.
on_decOutButton_clicked | Private slot to send a decimal number.
on_hexEdit_textChanged | Private slot to handle input of a hexadecimal number.
on_hexInButton_clicked | Private slot to retrieve a hexadecimal number from the current editor.
on_hexOutButton_clicked | Private slot to send a hexadecimal number.
on_octEdit_textChanged | Private slot to handle input of an octal number.
on_octInButton_clicked | Private slot to retrieve an octal number from the current editor.
on_octOutButton_clicked | Private slot to send an octal number.
on_sizeBox_valueChanged | Private slot handling a change of the bit size.

### Static Methods

None

#### NumbersWidget (Constructor)

NumbersWidget(parent=None)

Constructor

parent
  reference to the parent widget (QWidget)

#### NumbersWidget.__binModelDataChanged

__binModelDataChanged(start, end)

Private slot to handle a change of the binary model value by the user.

start
  start index (QModelIndex)
end
  end index (QModelIndex)

#### NumbersWidget.__block

__block(b)

Private slot to block some signals.

b
  flah indicating the blocking state (boolean)

#### NumbersWidget.__formatNumbers

__formatNumbers(numberFormat)

Private method to format the various number inputs.

numberFormat
  number format indicator (integer)

#### NumbersWidget.on_binEdit_textChanged

on_binEdit_textChanged(txt)

Private slot to handle input of a binary number.

txt
  text entered (string)

#### NumbersWidget.on_binInButton_clicked

on_binInButton_clicked()

Private slot to retrieve a binary number from the current editor.

#### NumbersWidget.on_binOutButton_clicked

on_binOutButton_clicked()

Private slot to send a binary number.

#### NumbersWidget.on_byteOrderButton_clicked

on_byteOrderButton_clicked()

Private slot to swap the byte order.

#### NumbersWidget.on_decEdit_textChanged

on_decEdit_textChanged(txt)

Private slot to handle input of a decimal number.

txt
  text entered (string)

#### NumbersWidget.on_decInButton_clicked

on_decInButton_clicked()

Private slot to retrieve a decimal number from the current editor.

#### NumbersWidget.on_decOutButton_clicked

on_decOutButton_clicked()

Private slot to send a decimal number.

#### NumbersWidget.on_hexEdit_textChanged

on_hexEdit_textChanged(txt)

Private slot to handle input of a hexadecimal number.

txt
  text entered (string)

#### NumbersWidget.on_hexInButton_clicked

on_hexInButton_clicked()

Private slot to retrieve a hexadecimal number from the current editor.

#### NumbersWidget.on_hexOutButton_clicked

on_hexOutButton_clicked()

Private slot to send a hexadecimal number.

#### NumbersWidget.on_octEdit_textChanged

on_octEdit_textChanged(txt)

Private slot to handle input of an octal number.

txt
  text entered (string)

#### NumbersWidget.on_octInButton_clicked

on_octInButton_clicked()

Private slot to retrieve an octal number from the current editor.

#### NumbersWidget.on_octOutButton_clicked

on_octOutButton_clicked()

Private slot to send an octal number.

#### NumbersWidget.on_sizeBox_valueChanged

on_sizeBox_valueChanged(value)

Private slot handling a change of the bit size.

value
  selected bit size (integer)

Up