SecureEditText

class vanilla.SecureEditText(posSize, text='', callback=None, continuous=True, readOnly=False, formatter=None, placeholder=None, sizeStyle='regular')

Standard secure text entry control.

../_images/SecureEditText.png
from vanilla import Window, SecureEditText

class SecureEditTextDemo:

    def __init__(self):
        self.w = Window((120, 42))
        self.w.secureEditText = SecureEditText((10, 10, -10, 22),
                            text='abc123',
                            callback=self.secureEditTextCallback)
        self.w.open()

    def secureEditTextCallback(self, sender):
        print("text entry!", sender.get())

SecureEditTextDemo()

posSize Tuple of form (left, top, width, height) or “auto” representing the position and size of the text entry control.

Standard Dimensions
Regular H 22
Small H 19
Mini H 16

text An object representing the contents of the text entry control. If no formatter has been assigned to the control, this should be a string. If a formatter has been assigned, this should be an object of the type that the formatter expects.

callback The method to be called when the user enters text.

continuous If True, the callback (if any) will be called upon each keystroke, if False, only call the callback when editing finishes. Default is True.

readOnly Boolean representing if the text can be edited or not.

formatter A NSFormatter for controlling the display and input of the text entry.

placeholder A placeholder string to be shown when the text entry control is empty.

sizeStyle A string representing the desired size style of the text entry control. The options are:

“regular”
“small”
“mini”
addAutoPosSizeRules(rules, metrics=None)

Add auto layout rules for controls/view in this view.

rules must be a list of rule definitions. Rule definitions may take two forms:

key value
“view1” The vanilla wrapped view for the left side of the rule.
“attribute1” The attribute of the view for the left side of the rule. See below for options.
“relation” (optional) The relationship between the left side of the rule and the right side of the rule. See below for options. The default value is “==”.
“view2” The vanilla wrapped view for the right side of the rule.
“attribute2” The attribute of the view for the right side of the rule. See below for options.
“multiplier” (optional) The constant multiplied with the attribute on the right side of the rule as part of getting the modified attribute. The default value is 1.
“constant” (optional) The constant added to the multiplied attribute value on the right side of the rule to yield the final modified attribute. The default value is 0.

The attribute1 and attribute2 options are:

value AppKit equivalent
“left” NSLayoutAttributeLeft
“right” NSLayoutAttributeRight
“top” NSLayoutAttributeTop
“bottom” NSLayoutAttributeBottom
“leading” NSLayoutAttributeLeading
“trailing” NSLayoutAttributeTrailing
“width” NSLayoutAttributeWidth
“height” NSLayoutAttributeHeight
“centerX” NSLayoutAttributeCenterX
“centerY” NSLayoutAttributeCenterY
“baseline” NSLayoutAttributeBaseline
“lastBaseline” NSLayoutAttributeLastBaseline
“firstBaseline” NSLayoutAttributeFirstBaseline

Refer to the NSLayoutAttribute documentation for the information about what each of these do.

The relation options are:

value AppKit equivalent
“<=” NSLayoutRelationLessThanOrEqual
“==” NSLayoutRelationEqual
“>=” NSLayoutRelationGreaterThanOrEqual

Refer to the NSLayoutRelation documentation for the information about what each of these do.

metrics may be either None or a dict containing key value pairs representing metrics keywords used in the rules defined with strings.

enable(onOff)

Enable or disable the object. onOff should be a boolean.

get()

Get the contents of the text entry control.

If no formatter has been assigned to the control, this returns a string. If a formatter has been assigned, this returns an object which has been translated by the formatter.

getNSSecureTextField()

Return the NSSecureTextField that this object wraps.

getNSTextField()

Return the NSTextField that this object wraps.

getPlaceholder()

Get the placeholder string displayed in the control.

getPosSize()

The position and size of the object as a tuple of form (left, top, width, height).

getTitle()

Get the control title.

isEnabled()

Return a bool indicating if the object is enable or not.

isVisible()

Return a bool indicating if the object is visible or not.

move(x, y)

Move the object by x units and y units.

resize(width, height)

Change the size of the object to width and height.

selectAll()

Select all text in the text entry control.

set(value)

Set the contents of the text entry control.

value An object representing the contents of the text entry control. If no formatter has been assigned to the control, this should be a string. If a formatter has been assigned, this should be an object of the type that the formatter expects.

setPlaceholder(value)

Set value as the placeholder string to be displayed in the control. value must be a string.

setPosSize(posSize, animate=False)

Set the position and size of the object.

posSize A tuple of form (left, top, width, height).

animate A boolean flag telling to animate the transition. Off by default.

setTitle(title)

Set the control title.

title A string representing the title.

show(onOff)

Show or hide the object.

onOff A boolean value representing if the object should be shown or not.