Package mcbase :: Package widgets :: Module mcnumberedit :: Class MCNumberEdit
[hide private]
[frames] | no frames]

Class MCNumberEdit

source code


The class used for numeric input.

Instance Methods [hide private]
 
__init__(self, parent=None)
Creates an instance of MCNumberEdit
source code
 
constructCalculator(self)
Creates the calculator widget and prepares visual settings.
source code
bool
_filterInput(self, key, ch)
Filters the user input, disallows non numeric values to be entered.
source code
 
keyPressEvent(self, event)
Special keyPressEvent handler for MCNumberEdit widget.
source code
 
createSepKeyEvent(self, e)
Simulates a fractional part seperator key event.
source code
str
_reFormatNumberText(self, newText)
Calls the reFormatNumberText static method by using the current parameters for this widget.
source code
 
init(self, fracPrecision=None, dynamicFrac=False, limit=None, input=0, enableMinus=False, bottomLimit=None, fractionSep=None, thousandSep=None)
Sets the default parameters for this widget.
source code
 
set(self, inputVal)
Setter method.
source code
str
get(self)
Common get method for this widget.
source code
 
getDecimal(self)
Returns the widget value as a Decimal
source code
 
clear(self)
Sets the value to the initial set value.
source code
 
validate(self)
Controls if the calculator is closed or not.
source code
 
resultAvailable(self)
Called after the result is available from the calculator
source code
 
calculatorHidden(self)
Called after the calculator frame is closed.
source code
 
openCalculator(self, keyEvent=None)
Creates a calculator frame just below the widget.
source code
bool
isOpeningCalculator(self)
Returns if the widget is about to open a calculator frame.
source code
 
getKeyboardMode(self)
Returns keyboardMode state (Inherited from mcbase.widgets.mclineedit.MCLineEdit)
source code
 
getModelCode(self)
Returns modelCode (Inherited from mcbase.widgets.mcwidget.MCWidget)
source code
 
openKeyboard(self, keyEvent=None)
Opens virtual keyboard widget (Inherited from mcbase.widgets.mclineedit.MCLineEdit)
source code
 
resetKeyboardMode(self)
Resets keyboardMode state (Inherited from mcbase.widgets.mclineedit.MCLineEdit)
source code
 
resetModelCode(self)
Resets the modelCode of the widget (Inherited from mcbase.widgets.mcwidget.MCWidget)
source code
 
setKeyboardMode(self, mode=True)
Makes virtual keyboard available if mode is True. (Inherited from mcbase.widgets.mclineedit.MCLineEdit)
source code
 
setModelCode(self, modelCode=None)
Sets the modelCode of the widget (Inherited from mcbase.widgets.mcwidget.MCWidget)
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods [hide private]
str
reFormatNumberText(newText, fractionSep=None, fracPrecision=None, thousandSep=None, LineEditObj=None)
Splits the given text according to the fractional separator.
source code
str
reFormatFractionPart(newNumber, fracPrecision=None, LineEditObj=None)
Reformats the given fractional part.
source code
str
reFormatDecimalPart(newNumber, thousandSep=None)
Reformats the given decimal part.
source code
 
format(initPrms, setPrm='0')
Static method to be used for number formatting.
source code
Class Variables [hide private]
  keyboardMode = pyqtProperty('bool', getKeyboardMode, setKeyboa... (Inherited from mcbase.widgets.mclineedit.MCLineEdit)
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, parent=None)
(Constructor)

source code 

Creates an instance of MCNumberEdit

Overrides: object.__init__

_filterInput(self, key, ch)

source code 

Filters the user input, disallows non numeric values to be entered.

Parameters:
  • key - Qt key code for the pressed key
  • ch - Ascii code for the pressed key
Returns: bool
Returns True if the entered digit is valid, False otherwise

keyPressEvent(self, event)

source code 

Special keyPressEvent handler for MCNumberEdit widget.

Parameters:
  • event - Key press event
Overrides: mclineedit.MCLineEdit.keyPressEvent

_reFormatNumberText(self, newText)

source code 

Calls the reFormatNumberText static method by using the current parameters for this widget.

Parameters:
  • newText (str) - Text to be reformatted
Returns: str
Formatted text

reFormatNumberText(newText, fractionSep=None, fracPrecision=None, thousandSep=None, LineEditObj=None)
Static Method

source code 

Splits the given text according to the fractional separator. Then reformats both parts, combines them with the fractional separator and returns.

Parameters:
  • newText (str) - String to be reformatted
  • fractionSep (str) - Fractional seperator (i.e.: ',')
  • fracPrecision (int) - Fractional part precision
  • thousandSep (str) - Thousands seperator (i.e.: '.')
  • LineEditObj (MCLineEdit) - Optional MCLineEdit widget, if given dynamically adjusts the fractional part precision.
Returns: str
Newly formatted number text

reFormatFractionPart(newNumber, fracPrecision=None, LineEditObj=None)
Static Method

source code 

Reformats the given fractional part.

Parameters:
  • newNumber (str) - String to be reformatted
  • fracPrecision (int) - Fractional part precision
  • LineEditObj (MCLineEdit) - Optional MCLineEdit widget, if given dynamically adjusts the fractional part precision.
Returns: str
Newly formatted number text

reFormatDecimalPart(newNumber, thousandSep=None)
Static Method

source code 

Reformats the given decimal part.

Parameters:
  • newNumber (str) - String to be reformatted
  • thousandSep (str) - Thousands seperator (i.e.: '.')
Returns: str
Newly formatted number text

format(initPrms, setPrm='0')
Static Method

source code 

Static method to be used for number formatting.

Parameters:
  • initPrms (tuple) - Init parameters that should be passed to an init method.
  • setPrm - Set parameter to be sent to an instance.

init(self, fracPrecision=None, dynamicFrac=False, limit=None, input=0, enableMinus=False, bottomLimit=None, fractionSep=None, thousandSep=None)

source code 

Sets the default parameters for this widget.

Parameters:
  • fracPrecision (int) - Fractional part precision
  • dynamicFrac (bool) - Dynamic fractions to be used?
  • limit (str) - Upper limit for this widget
  • input (str) - Default value for widget
  • enableMinus (bool) - If True, negative numbers will be allowed.
  • fractionSep (str) - Fractional seperator (i.e.: ',')
  • thousandSep (str) - Thousands seperator (i.e.: '.'), default ' '

set(self, inputVal)

source code 

Setter method.

Parameters:
  • inputVal (str) - Value to be set, i.e '1125.52' or '1125,53'
Overrides: mclineedit.MCLineEdit.set

get(self)

source code 

Common get method for this widget.

Returns: str
A string that may be converted to float. i.e.: 1125.52
Overrides: mclineedit.MCLineEdit.get

resultAvailable(self)

source code 

Called after the result is available from the calculator

Overrides: mclineedit.MCLineEdit.resultAvailable

isOpeningCalculator(self)

source code 

Returns if the widget is about to open a calculator frame.

Returns: bool
If the calculator frame is opening or has already opened, returns True, otherwise returns False