TextBox

class vanilla.TextBox(posSize, text='', alignment='natural', selectable=False, sizeStyle='regular')

A rectangle containing static text.:

from vanilla import *

class TextBoxDemo(object):

     def __init__(self):
         self.w = Window((100, 37))
         self.w.textBox = TextBox((10, 10, -10, 17), "A TextBox")
         self.w.open()

TextBoxDemo()

posSize Tuple of form (left, top, width, height) representing the position and size of the text box.

Standard Dimensions
Regular H 17
Small H 14
Mini H 12

text The text to be displayed in the text box. If the object is a NSAttributedString, the attributes will be used for display.

alignment A string representing the desired visual alignment of the text in the text box. The options are:

“left” Text is aligned left.
“right” Text is aligned right.
“center” Text is centered.
“justified” Text is justified.
“natural” Follows the natural alignment of the text’s script.

selectable Boolean representing if the text is selectable or not.

sizeStyle A string representing the desired size style of the button. The options are:

“regular”
“small”
“mini”
getNSTextField()

Return the NSTextField that this object wraps.

get()

Get the contents of the text box.

set(value)

Set the contents of the text box.

value A string representing the contents of the text box.

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.