EditText

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

Standard short text entry control.:

from vanilla import *

class EditTextDemo(object):

    def __init__(self):
        self.w = Window((100, 42))
        self.w.editText = EditText((10, 10, -10, 22),
                            callback=self.editTextCallback)
        self.w.open()

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

EditTextDemo()

posSize Tuple of form (left, top, width, height) 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 An 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”
getNSTextField()

Return the NSTextField that this object wraps.

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.

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.

getPlaceholder()

Get the placeholder string displayed in the control.

setPlaceholder(value)

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

selectAll()

Select all text in the text entry control.

enable(onOff)

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

getPosSize()

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

getTitle()

Get the control title.

isVisible()

Return a bool indicting 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.

setPosSize(posSize)

Set the postion and size of the object.

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

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.