Items
Static
A line of text. |
|
|
A horizontal line. |
|
A vertical line. |
An image. |
Buttons
A push button. |
|
A push button with an image. |
|
A help button. |
|
A settings button. |
|
A button with add and remove segments. |
|
A stepper button. |
Selectors
A pop up button. |
|
A button with sub segments. |
|
A group of radio buttons. |
|
A checkbox, optionally with text next to it. |
|
A group of checkboxes. |
|
A switch. |
|
A slider. |
|
A slider and a label. |
|
A slider and a text field. |
|
A slider, a text field and a stepper. |
|
A control that shows a color and, when pressed, displays the system color picker. |
Menu Buttons
A pull down button that displays a menu. |
|
An action button. |
Text Input
A field with editable text. |
|
A text field and a stepper. |
|
A combo box. |
|
A multi-line text editor. |
Progress Indicators
A progress bar. |
|
A progress spinner. |
Table
A table of data. |
|
A table of files. |
|
A table of fontParts fonts. |
|
A group row item. |
Views
A MerzView. |
|
A ScrollingMerzView. |
|
A web view. |
Label
- class ezui.Label
A line of text. Label usage reference.
To create a Label with a text description, use any text that doesn’t match any other text description pattern.
This is a label.
If you want to change the style of the label from the default, append 1-11
!
followed by a space before your text.! This is a label. !! This is a label. !!! This is a label. !!!! This is a label. !!!!! This is a label. !!!!!! This is a label. !!!!!!! This is a label. !!!!!!!! This is a label. !!!!!!!!! This is a label. !!!!!!!!!! This is a label.
Common styles are accessible with the following.
!§ This is the section header style. This is the body style. !- This is the caption style. !* This is the footnote style.
class DemoController(ezui.WindowController): def build(self): content = """ Some text. ----- ! Some text with largeTitle style. !! Some text with title1 style. !!! Some text with title2 style. !!!! Some text with title3 style. !!!!! Some text with headline style. !!!!!! Some text with subheadline style. !!!!!!! Some text with body style. !!!!!!!! Some text with callout style. !!!!!!!!! Some text with footnote style. !!!!!!!!!! Some text with caption1 style. !!!!!!!!!!! Some text with caption2 style. ----- !§ This is the section header style. This is the body style. !- This is the caption style. !* This is the footnote style. """ self.w = ezui.EZWindow( title="Demo", size=(400, "auto"), content=content, controller=self ) def started(self): self.w.open() DemoController()
Description Data
text
The text to display.valueType
The type of value allowed to be displayed."string"
"stringList"
"number"
"numberList"
"integer"
"integerList"
"float"
"floatList"
number, numberList, float and floatList default to rounding to three decimal places for display in the label. If you want more or less precision, add “:#” to the value type where “#” is an integer.
valueFallback
The value to return when the text can’t be converted tovalueType
.valueListDelimiter
The delimiter to use when breaking the value into lists.valueToStringConverter
A value to string converter. Optional.stringToValueConverter
A string to value converter. Optional.stringFormatter
A string formatter. Optional.style
The system defined text style.sizeStyle
The size of the item."mini"
"small"
"regular"
alignment
The alignment of the text."left"
"right"
"center"
"justified"
"natural"
(default)
- get()
Get the text.
- set(value)
Set the text.
- enable(onOff)
Enable or disable the object. onOff should be a boolean.
- show(onOff)
Show or hide the object.
onOff A boolean value representing if the object should be shown or not.
Line
- class ezui.Line
A line. It will be horizontal or vertical depending on the type of container it is in.
To create a Line with a text description, use a line of text containing 1 or more hyphens.
----------
import ezui class DemoController(ezui.WindowController): def build(self): content = """ --------------- """ self.w = ezui.EZWindow( title="Demo", size=(300, 100), content=content, controller=self ) def started(self): self.w.open() DemoController()
Description Data
There are no options. It’s just a line.
- show(onOff)
Show or hide the object.
onOff A boolean value representing if the object should be shown or not.
Image
- class ezui.Image
An image. Image usage reference.
import AppKit import ezui class DemoController(ezui.WindowController): def build(self): content = """ * Image @image1 * Image @image2 """ descriptionData = dict( image1=dict( image=ezui.makeImage( imageName=AppKit.NSImageNameTrashFull ) ), image2=dict( image=ezui.makeImage( imageName=AppKit.NSImageNameTrashEmpty ) ) ) self.w = ezui.EZWindow( title="Demo", size=(200, "auto"), content=content, descriptionData=descriptionData, controller=self ) def started(self): self.w.open() DemoController()
Description Data
image
ANSImage
object to display. UsemakeImage()
to create the object.symbolConfiguration
A symbol configuration for the symbol. SeemakeSymbolConfiguration()
for details. Optional.- show(onOff)
Show or hide the object.
onOff A boolean value representing if the object should be shown or not.
Stepper
- class ezui.Stepper
A stepper button. Steppers are almost always used in combination with a :py:class:TextField. An item group combining A
TextField
and aStepper
is availabe with :py:class:TextFieldAndStepper. Stepper usage reference.A Stepper is created with the string
(±)
.[__](±) @identifier
import ezui class DemoController(ezui.WindowController): def build(self): content = """ (±) @myStepper """ descriptionData = dict( myStepper=dict( valueType="integer", value=50, minValue=0, maxValue=100, valueIncrement=10 ) ) self.w = ezui.EZWindow( content=content, descriptionData=descriptionData, controller=self, size=(300, "auto") ) def started(self): self.w.open() def myStepperCallback(self, sender): print("Stepper:", sender.get()) DemoController()
Description Data
valueType
The type of value allowed to be entered."integer"
"float"
minValue
The minimum value for the stepper.maxValue
The maximum value for the stepper.value
The starting value for the stepper.valueIncrement
The increment to be added/subtracted when the stepper is pressed.autoRepeats
If the stepper auto-repeats.callback
The function to call when the stepper is pressed.- get()
Get the value from the stepper.
- set(value)
Set a value into the stepper.
- enable(onOff)
Enable or disable the object. onOff should be a boolean.
- show(onOff)
Show or hide the object.
onOff A boolean value representing if the object should be shown or not.
Checkbox
- class ezui.Checkbox
A checkbox, optionally with text next to it. Checkbox usage reference.
A Checkbox is created with a line starting with
[ ]
,[X]
or[-]
.( )
indicates that the checkbox is unselected.[X]
indicates that the checkbox is selected.[-]
indicates that the checkbox is in a mixed state.[ ] Checkbox
[X] Checkbox
[-] Checkbox
import ezui class DemoController(ezui.WindowController): def build(self): content = """ [ ] On/Off @onOffCheckbox ---------- [ ] Mixed @mixedCheckbox """ descriptionData = dict( mixedCheckbox=dict( allowMixedState=True ) ) self.w = ezui.EZWindow( title="Demo", content=content, descriptionData=descriptionData, controller=self ) def started(self): self.w.open() def onOffCheckboxCallback(self, sender): print("onOffCheckbox:", sender.get()) def mixedCheckboxCallback(self, sender): print("mixedCheckbox:", sender.get()) DemoController()
Description Data
text
The text next to the checkbox.value
The state of the checkbox.value
state
False
or0
off
True
or1
on
-1
mixed (only when
allowMixedState
isTrue
)allowMixedState
If the checkbox allows mixed state.callback
The function to call when the checkbox is checked/unchecked.sizeStyle
The size of the item."mini"
"small"
"regular"
- get()
Get the value of the checkbox.
- set(value)
Set the value of the checkbox.
- toggle()
Toggle the state of the check box.
If the check box is on, turn it off. If the check box is off, turn it on.
- getTitle()
Get the control title.
- setTitle(title)
Set the control title.
title A string representing the title.
- enable(onOff)
Enable or disable the object. onOff should be a boolean.
- show(onOff)
Show or hide the object.
onOff A boolean value representing if the object should be shown or not.
Checkboxes
- class ezui.Checkboxes
A group of checkboxes. Checkboxes usage reference.
Text Description
Checkboxes are created with two lines starting with
[ ]
,[X]
or[-]
.( )
indicates that the checkbox is unselected.[X]
indicates that the checkbox is selected.[-]
indicates that the checkbox is in a mixed state.[ ] Checkbox 1 [X] Checkbox 2 [-] Checkbox 3
import ezui class DemoController(ezui.WindowController): def build(self): content = """ [ ] On/Off @onOffCheckbox [ ] Mixed @mixedCheckbox """ descriptionData = dict( mixedCheckbox=dict( allowMixedState=True ) ) self.w = ezui.EZWindow( title="Demo", content=content, descriptionData=descriptionData, controller=self ) def started(self): self.w.open() def onOffCheckboxCallback(self, sender): print("onOffCheckbox:", sender.get()) def mixedCheckboxCallback(self, sender): print("mixedCheckbox:", sender.get()) DemoController()
Description Data
checkboxDescriptions
A list of checkbox descriptions as dictionaries. See :py:class:Checkbox for key/value options.- enable(onOff)
Enable or disable the object. onOff should be a boolean.
- show(onOff)
Show or hide the object.
onOff A boolean value representing if the object should be shown or not.
Switch
- class ezui.Switch
A switch. Switch usage reference.
To create a Switch with a text description, use
(-X)
or(X-)
.(-X)
indicates that the button should be selected.(X-)
indicates that the button should not be selected.(-X) @identifier (X-) @identifier
import ezui class DemoController(ezui.WindowController): def build(self): content = """ (X-) @switch """ descriptionData = dict( switch1=dict( value=False ) ) self.w = ezui.EZWindow( content=content, descriptionData=descriptionData, controller=self, ) def started(self): self.w.open() def switchCallback(self, sender): print("switch:", sender.get()) DemoController()
Description Data
callback
The function to call when the button is pushed.value
The state of the button.- get()
Get the value of the switch.
- set(value)
Set the value of the switch.
- enable(onOff)
Enable or disable the object. onOff should be a boolean.
- show(onOff)
Show or hide the object.
onOff A boolean value representing if the object should be shown or not.
Slider
- class ezui.Slider
A slider. Slider usage reference.
A Slider is defined with a line containing one or more
-
and oneX
.Optionally the Slider can be circular with a
Ø
.-----X----- @identifier
import ezui class DemoController(ezui.WindowController): def build(self): content = """ -----X--------------- @noTickMarks ----------X---------- @withTickMarks ---------------X----- @stopOnTickMarks Ø @circularSlider """ descriptionData = dict( noTickMarks=dict( minValue=0, maxValue=1, value=0.25 ), withTickMarks=dict( minValue=0, maxValue=1, value=0.5, tickMarks=10 ), stopOnTickMarks=dict( minValue=0, maxValue=1, value=0.75, tickMarks=10, stopOnTickMarks=True ) ) self.w = ezui.EZWindow( title="Demo", size=(200, "auto"), content=content, descriptionData=descriptionData, controller=self ) def started(self): self.w.open() def noTickMarksCallback(self, sender): print("noTickMarks:", sender.get()) def withTickMarksCallback(self, sender): print("withTickMarks:", sender.get()) def stopOnTickMarksCallback(self, sender): print("stopOnTickMarks:", sender.get()) DemoController()
Description Data
minValue
The minimum value for the slider.maxValue
The maximum value for the slider.value
The starting value for the slider.tickMarks
The number of tick marks.None
or a number.stopOnTickMarks
If the slider only stops on the tick marks.continuous
If the slider calls the callback continuously or only after the user has stopped moving the knob.callback
The function to call when the slider is slid.sizeStyle
The size of the item."mini"
"small"
"regular"
- get()
Get the value of the slider.
- set(value)
Set the value of the slider.
- enable(onOff)
Enable or disable the object. onOff should be a boolean.
- show(onOff)
Show or hide the object.
onOff A boolean value representing if the object should be shown or not.
SliderAndLabel
- class ezui.SliderAndLabel
A slider and a label. See Slider and Label for documentation on the components.
A SliderAndLabel is defined with a line containing one or more
-
and oneX
followed by a space followed by text.Optionally the Slider can be circular with a
Ø
.-----X----- [__] @identifier
import ezui class DemoController(ezui.WindowController): def build(self): content = """ ---X--- 123 @mySlider """ descriptionData = dict( mySlider=dict( valueType="integer", value=50, minValue=0, maxValue=100 ) ) self.w = ezui.EZWindow( content=content, descriptionData=descriptionData, controller=self, size=(300, "auto") ) def started(self): self.w.open() def mySliderCallback(self, sender): print("Slider:", sender.get()) DemoController()
Description Data
sliderWidth
The width of the Slider.labelWidth
The width of the TextField.callback
The function to call when the slider is slid.- enable(onOff)
Enable or disable the object. onOff should be a boolean.
- show(onOff)
Show or hide the object.
onOff A boolean value representing if the object should be shown or not.
SliderAndTextField
- class ezui.SliderAndTextField
A slider and a text field. See Slider and TextField for documentation on the components.
A SliderAndTextField is defined with a line containing one or more
-
and oneX
followed by a space followed by[_
and ending with_]
.Optionally the Slider can be circular with a
Ø
.-----X----- [__] @identifier
import ezui class DemoController(ezui.WindowController): def build(self): content = """ ---X--- [__] @mySlider """ descriptionData = dict( mySlider=dict( valueType="integer", value=50, minValue=0, maxValue=100 ) ) self.w = ezui.EZWindow( content=content, descriptionData=descriptionData, controller=self, size=(300, "auto") ) def started(self): self.w.open() def mySliderCallback(self, sender): print("Slider:", sender.get()) def mySliderTextFieldCallback(self, sender): print("TextField:", sender.get()) DemoController()
Description Data
sliderWidth
The width of the Slider.textFieldWidth
The width of the TextField.callback
The function to call when the slider is slid or when the text is changed.- enable(onOff)
Enable or disable the object. onOff should be a boolean.
- show(onOff)
Show or hide the object.
onOff A boolean value representing if the object should be shown or not.
SliderTextFieldAndStepper
- class ezui.SliderTextFieldAndStepper
A slider, a text field and a stepper. See Slider, TextField and stepper for documentation on the components.
A SliderTextFieldAndStepper is defined with a line containing one or more
-
and oneX
followed by a space followed by[_
and ending with_](±)
.Optionally the Slider can be circular with a
Ø
.-----X----- [__](±) @identifier
import ezui class DemoController(ezui.WindowController): def build(self): content = """ ---X--- [__](±) @mySliderTextFieldAndStepper """ descriptionData = dict( mySlider=dict( valueType="integer", value=50, minValue=0, maxValue=100 ) ) self.w = ezui.EZWindow( content=content, descriptionData=descriptionData, controller=self, size=(300, "auto") ) def started(self): self.w.open() def mySliderTextFieldAndStepperCallback(self, sender): print("SliderTextFieldAndStepper:", sender.get()) DemoController()
Description Data
sliderWidth
The width of the Slider.textFieldWidth
The width of the TextField.callback
The function to call when the slider is slid or when the text is changed.- enable(onOff)
Enable or disable the object. onOff should be a boolean.
- show(onOff)
Show or hide the object.
onOff A boolean value representing if the object should be shown or not.
TextField
- class ezui.TextField
A field with editable text. TextField usage reference.
A TextField is created with a line starting with
[_
and ending with_]
. Any text enclosed, , except all_
, will be used as the default value.[_This is a TextField._] @identifier
You can add leading and/ or trailing text by adding text before and/are after the
[]
.Some leading text. [_This is a TextField._] Some trailing text. @identifier
You can add leading and/ or trailing images by adding enclosing SF Symbol names in
{}
before and/are after the[__]
.{square.fill} [_This is a TextField._] {circle.fill} @identifier
import ezui def colorNumberFormatter(attributes): value = attributes["value"] if value is None: color = (0.5, 1, 0, 1) elif value < 0: color = (1, 0, 0, 1) elif value > 0: color = (0, 1, 0, 1) else: color = (0, 0, 1, 1) attributes["fillColor"] = color class DemoController(ezui.WindowController): def build(self): content = """ [_String. _] @stringTextField [_List of strings._] @stringListTextField [_1 _] @numberTextField [_1 2.3 4 _] @numberListTextField [_1 _] @integerTextField [_1.2 _] @floatTextField [_1.2 3.4 5.6 _] @floatListTextField ----- Formatting. [_ _] @formattedTextField ----- Leading text. [______] Trailing text. ----- {hare.fill} [______] {tortoise.fill} """ descriptionData = dict( stringTextField=dict( placeholder="Enter a string.", valueType="string" ), stringListTextField=dict( placeholder="Enter a list of strings.", valueType="stringList" ), numberTextField=dict( placeholder="Enter a number.", valueType="number" ), numberListTextField=dict( placeholder="Enter a list of numbers.", valueType="numberList" ), integerTextField=dict( placeholder="Enter an integer.", valueType="integer" ), floatTextField=dict( placeholder="Enter a float.", valueType="float" ), floatListTextField = dict( placeholder="Enter a list of floats.", valueType="floatList" ), formattedTextField=dict( placeholder="Enter a number.", valueType="number", stringFormatter=colorNumberFormatter, value=-1, ) ) self.w = ezui.EZWindow( title="Demo", size=(300, "auto"), content=content, descriptionData=descriptionData, controller=self ) def started(self): self.w.open() def stringTextFieldCallback(self, sender): print(f"stringTextField: {sender.get()} {type(sender.get())}") def stringListTextFieldCallback(self, sender): print(f"stringListTextField: {sender.get()} {type(sender.get())}") def numberTextFieldCallback(self, sender): print(f"numberTextField: {sender.get()} {type(sender.get())}") def numberListTextFieldCallback(self, sender): print(f"numberListTextField: {sender.get()} {type(sender.get())}") def integerTextFieldCallback(self, sender): print(f"integerTextField: {sender.get()} {type(sender.get())}") def integerListTextFieldCallback(self, sender): print(f"integerListTextField: {sender.get()} {type(sender.get())}") def floatTextFieldCallback(self, sender): print(f"floatTextField: {sender.get()} {type(sender.get())}") def floatListTextFieldCallback(self, sender): print(f"floatListTextField: {sender.get()} {type(sender.get())}") DemoController()
Description Data
text
The text in the field.placeholder
The placeholder text.valueType
The type of value allowed to be entered."string"
"stringList"
"number"
"numberList"
"integer"
"integerList"
"float"
"floatList"
number, numberList, float and floatList default to rounding to three decimal places for display in the field. If you want more or less precision, add “:#” to the value type where “#” is an integer.
valueFallback
The value to return when the text can’t be converted tovalueType
.valueListDelimiter
The delimiter to use when breaking the value into lists.minValueListItems
The minimum number of items allowed when breaking the value into lists.maxValueListItems
The maxium number of items allowed when breaking the value into lists.valueIncrement
The value to add/substract when the up and down arrow keys are pressed.minValue
The minimum allowed value.maxValue
The maximum allowed value.evaluateValueAsEquation
If simple math equations may be entered instead of absolute values.valueToStringConverter
A value to string converter. Optional.stringToValueConverter
A string to value converter. Optional.stringFormatter
A string formatter. Optional.valueWidth
The width of the value entry field.leadingText
The leading text.leadingImage
The leading image. UsemakeImage()
to create the object.leadingTextWidth
The width of the leading text.leadingImageWidth
The width of the leading image.trailingText
The trailing text.trailingImage
The trailing image. UsemakeImage()
to create the object.trailingTextWidth
The trailing text width.trailingImageWidth
The trailing image width.continuous
If the callback is called immidiately after every key press.callback
The function to call when the text is changed.sizeStyle
The size of the item."mini"
"small"
"regular"
- get()
Get the text.
- set(value)
Set the text.
- show(onOff)
Show or hide the object.
onOff A boolean value representing if the object should be shown or not.
- setFont(name=None, systemStyle=None, size=None, weight=None, designStyle=None, sizeStyle='regular')
Set the font in the field.
This uses
makeFont()
to create the NSFont. Refer tomakeFont
for documentation on the possible arguments.
- enable(onOff)
Enable or disable the object. onOff should be a boolean.
TextFieldAndStepper
- class ezui.TextFieldAndStepper
A text field and a stepper. See TextField and Stepper for documentation on the components.
A TextFieldAndStepper is defined with a line containing
[_
and ending with_](±)
.[__](±) @identifier
import ezui class DemoController(ezui.WindowController): def build(self): content = """ [__](±) @myTextFieldAndStepper """ descriptionData = dict( myTextFieldAndStepper=dict( valueType="integer", value=50, minValue=0, maxValue=100, valueIncrement=10 ) ) self.w = ezui.EZWindow( content=content, descriptionData=descriptionData, controller=self, size=(300, "auto") ) def started(self): self.w.open() def myTextFieldAndStepperCallback(self, sender): print("TextFieldAndStepper:", sender.get()) DemoController()
Description Data
textFieldWidth
The width of the TextField.callback
The function to call when the stepper is pushed or when the text is changed.- enable(onOff)
Enable or disable the object. onOff should be a boolean.
- show(onOff)
Show or hide the object.
onOff A boolean value representing if the object should be shown or not.
ComboBox
- class ezui.ComboBox
A combo box. ComboBox usage reference.
A ComboBox is created with a line that starts with
[_
and ends with...]
. Any enclosed text will be used as the default value.[_This is a ComboBox. ...]
import ezui class DemoController(ezui.WindowController): def build(self): content = """ [_This is a ComboBox. ...] @comboBox """ descriptionData = dict( comboBox=dict( items=[ "AAA", "BBB", "CCC" ] ) ) self.w = ezui.EZWindow( title="Demo", size=(300, "auto"), content=content, descriptionData=descriptionData, controller=self ) def started(self): self.w.open() def comboBoxCallback(self, sender): print(f"comboBox: {sender.get()}") DemoController()
Description Data
items
A list of string options for the combo box.A dict of form
{display value : internal value}
may given instead of a list. In this case:the dict’s keys will be the items shown in the combo box.
get
will return the internal value when the displayed value is a key in the dict.set
will accept either the display or internal value. It will display the display value whenever possible.
value
The default value.continuous
If the callback is called after each key down event or only when the user is finished editing.RoboFont Addition
If you want to present a list of glyph names from a font in the combo box, a dict of items is available as a representation.
items = font.asDefcon().unicodeData.getRepresentation( "ezuiGlyphSearchValues" )
This representation factory has the following options:
onlyGlyphNames
A list of glyph names to use. If none are given, all glyph names in the font will be used.useGlyphOrder
A boolean indicating if you want to use the font’s glyph order sintead of alphabetical order. The default isFalse
.sortBySuffix
A boolean indicating if you want the glyphs sorted into suffix groups. The default isTrue
.includeGlyphNames
A boolean indicating if you want glyph names included in the display values. The default isTrue
.includeUnicodes
A boolean indicating if you want unicodes included in the display values. The default isTrue
.includeSuffixedUnicodes
A boolean indicating if you want suffixed unicodes (ex: 0041.sc) included in the display values. The default isTrue
.includeCharacters
A boolean indicating if you want characters included in the display values. The default isTrue
.includeSuffixedCharacters
A boolean indicating if you want suffixed characters (ex: $.sc) included in the display values. The default isTrue
.
- get()
Get the text entered in the combo box.
- set(value)
Set the text in the text field of the combo box.
value A string to set in the combo box.
- setItems(items)
Set the items in the combo box list.
items A list of strings to set in the combo box list.
- getItems()
Get the items in the combo box as a list.
- enable(onOff)
Enable or disable the object. onOff should be a boolean.
- show(onOff)
Show or hide the object.
onOff A boolean value representing if the object should be shown or not.
ColorWell
- class ezui.ColorWell
A control that shows a color and, when pressed, displays the system color picker. ColorWell usage reference.
To create a ColorWell with a text description, use the item type name token
* ColorWell
.import ezui class DemoController(ezui.WindowController): def build(self): content = """ * ColorWell @colorWell1 * ColorWell @colorWell2 """ descriptionData = dict( colorWell1=dict( color=(1, 0, 0, 1) ), colorWell2=dict( color=(0, 0, 1, 1) ) ) self.w = ezui.EZWindow( title="Demo", size=(200, "auto"), content=content, descriptionData=descriptionData, controller=self ) def started(self): self.w.open() def colorWell1Callback(self, sender): print("colorWell1:", sender.get()) def colorWell2Callback(self, sender): print("colorWell2:", sender.get()) DemoController()
Description Data
color
The color to set.callback
The function to call when a color is chosen.- get()
Get the color.
- set(color)
Set the color.
- enable(onOff)
Enable or disable the object. onOff should be a boolean.
- show(onOff)
Show or hide the object.
onOff A boolean value representing if the object should be shown or not.
TextEditor
- class ezui.TextEditor
A multi-line text editor. TextEditor usage reference.
A TextEditor is created with a line starting with
[[_
and ending with _]]
. Any text enclosed will be used as the default value.[[_This is a TextEditor._]]
The editor can be set to be non-editable by adding
~
inside the[[_
and_]]
.[[_~ This is a non-editable TextEditor. ~_]]
import ezui class DemoController(ezui.WindowController): def build(self): content = """ [[_This is editable text. _]] @textEditor1 [[_~ This is read only text. ~_]] @textEditor2 """ self.w = ezui.EZWindow( title="Demo", size=(300, 200), content=content, controller=self ) def started(self): self.w.open() def textEditor1Callback(self, sender): print(sender.get()) DemoController()
Description Data
value
The text in the editor.editable
If the text is editable.callback
The function to call when the text is changed.sizeStyle
The size of the item."mini"
"small"
"regular"
- get()
Get the contents of the text entry control.
- 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.
- show(onOff)
Show or hide the object.
onOff A boolean value representing if the object should be shown or not.
ProgressBar
- class ezui.ProgressBar
A progress bar. ProgressBar usage reference.
A ProgressBar is created with a line containing only
%
or%
and-
.%%%-------
If the line contains only
%
the progress bar will show a looping animation.%%%%%%%%%%
import ezui class DemoController(ezui.WindowController): def build(self): content = """ %%%------- @progressBar1 %%%%%%%%%% @progressBar2 ---------- (Go) @goButton """ descriptionData = dict( progressBar1=dict( minValue=0, maxValue=5 ) ) self.w = ezui.EZWindow( title="Demo", size=(300, "auto"), content=content, descriptionData=descriptionData, controller=self ) def started(self): self.w.open() progressBar2Animating = False def goButtonCallback(self, sender): progressBar1 = self.w.getItem("progressBar1") progressBar2 = self.w.getItem("progressBar2") if progressBar1.get() == 5: progressBar1.set(0) else: progressBar1.increment() if self.progressBar2Animating: progressBar2.stop() self.progressBar2Animating = False else: progressBar2.start() self.progressBar2Animating = True DemoController()
Description Data
minValue
The minimum value for the bar. If this isNone
the bar will show a looping animation.maxValue
The maximum value for the bar. If this isNone
the bar will show a looping animation.value
The initial value of the bar. If this isNone
,minValue
will be used.showWhenStopped
If the bar should be shown when stopped.- get()
Get the current value of the progress bar.
Only available in determinate progress bars.
- set(value)
Set the value of the progress bar to value.
Only available in determinate progress bars.
- increment(value=1)
Increment the progress bar by value.
Only available in determinate progress bars.
- start()
Start the animation.
Only available in indeterminate progress bars.
- stop()
Stop the animation.
Only available in indeterminate progress bars.
- enable(onOff)
Enable or disable the object. onOff should be a boolean.
- show(onOff)
Show or hide the object.
onOff A boolean value representing if the object should be shown or not.
ProgressSpinner
- class ezui.ProgressSpinner
A progress spinner. ProgressSpinner usage reference.
A ProgressSpinner is created with a line containing only
%
or%%
.%
If the line contains
%%
the progress spinner will show a looping animation.%%
import ezui class DemoController(ezui.WindowController): def build(self): content = """ % @progressSpinner1 %% @progressSpinner2 ---------- (Go) @goButton """ descriptionData = dict( progressSpinner1=dict( minValue=0, maxValue=5 ) ) self.w = ezui.EZWindow( title="Demo", content=content, descriptionData=descriptionData, controller=self ) def started(self): self.w.open() progressSpinner2Animating = False def goButtonCallback(self, sender): progressSpinner1 = self.w.getItem("progressSpinner1") progressSpinner2 = self.w.getItem("progressSpinner2") if progressSpinner1.get() == 5: progressSpinner1.set(0) else: progressSpinner1.increment() if self.progressSpinner2Animating: progressSpinner2.stop() self.progressSpinner2Animating = False else: progressSpinner2.start() self.progressSpinner2Animating = True DemoController()
Description Data
minValue
The minimum value for the spinner. If this isNone
the spinner will show a looping animation.maxValue
The maximum value for the spinner. If this isNone
the spinner will show a looping animation.value
The initial value of the spinner. If this isNone
,minValue
will be used.showWhenStopped
If the spinner should be shown when stopped.sizeStyle
The size of the item."mini"
"small"
"regular"
- get()
Get the current value of the progress bar.
Only available in determinate progress bars.
- set(value)
Set the value of the progress bar to value.
Only available in determinate progress bars.
- increment(value=1)
Increment the progress bar by value.
Only available in determinate progress bars.
- start()
Start the animation.
Only available in indeterminate progress bars.
- stop()
Stop the animation.
Only available in indeterminate progress bars.
- enable(onOff)
Enable or disable the object. onOff should be a boolean.
- show(onOff)
Show or hide the object.
onOff A boolean value representing if the object should be shown or not.
Table
- class ezui.Table
A table of data. This is a simplified version of vanilla.List2.
A table is created with a line that starts with
|
and ends with|
followed by an identifier.| | @identifier
All text between the
|
and|
will be ignored. Lines that begin with|
and end with|
but do not have an identifier will be ignored. This allows for ASCII-art like representations of tables.|-----------------------------| | letter | numbers | value | @complexTable |--------|---------|----------| | A | 1 | --X----- | | | | | |-----------------------------|
A table may have a footer. This can be defined within the text description or with the
footer
argument defined below. To define the footer within the text description, follow the table description with items preceded by>
and the items will be added to the footer.import ezui class DemoController(ezui.WindowController): def build(self): content = """ = HorizontalStack |-----------------------------| @simpleTable | | |-----------------------------| |-----------------------------| | letter | numbers | value | @complexTable |--------|---------|----------| | A | 1 | --X----- | | | | | |-----------------------------| > (+-) @complexTableAddRemoveButton > (Print) @complexTablePrintButton """ simpleTableItems = [ "A", "B", "C" ] complexTableItems = [ dict( letter="A", numbers=[1], value=0 ), dict( letter="B", numbers=[2, 2], value=0.5 ), dict( letter="C", numbers=[3, 3, 3], value=1 ), ] descriptionData = dict( simpleTable=dict( width=100, items=simpleTableItems ), complexTable=dict( width=300, items=complexTableItems, columnDescriptions=[ dict( identifier="letter", title="Letter", width=35, editable=True ), dict( identifier="numbers", title="Numbers", width=50, cellDescription=dict( valueType="integerList" ), editable=True ), dict( identifier="value", title="Value", cellDescription=dict( cellType="Slider", valueType="float", cellClassArguments=dict( minValue=0, maxValue=1 ), ), editable=True ) ] ) ) self.w = ezui.EZWindow( title="Demo", size=("auto", 200), content=content, descriptionData=descriptionData, controller=self ) def started(self): self.w.open() def simpleTableSelectionCallback(self, sender): print("simpleTable selection:", sender.getSelectedItems()) def complexTableAddRemoveButtonAddCallback(self, sender): table = self.w.getItem("complexTable") item = table.makeItem( letter="X", numbers=[0] ) table.appendItems([item]) def complexTableAddRemoveButtonRemoveCallback(self, sender): table = self.w.getItem("complexTable") table.removeSelectedItems() def complexTablePrintButtonCallback(self, sender): import pprint table = self.w.getItem("complexTable") print("complexTable items:") pprint.pprint(table.get()) DemoController()
import ezui items = [ dict( imageValue=ezui.makeImage(symbolName="gift.fill"), textValue="One", popUpValue=0, sliderValue=0, colorValue=(1, 0, 0, 1) ), dict( imageValue=ezui.makeImage(symbolName="trophy.fill"), textValue="Two", popUpValue=1, sliderValue=0.5, colorValue=(0, 1, 0, 1) ), dict( imageValue=ezui.makeImage(symbolName="banknote.fill"), textValue="Three", popUpValue=2, sliderValue=1, colorValue=(0, 0, 1, 1) ), ] class DemoController(ezui.WindowController): def build(self): content = """ | ----------------- | @table | im | tf | pu | sl | | ----------------- | """ descriptionData = dict( table=dict( items=items, columnDescriptions=[ dict( identifier="imageValue", title="Image", width=50, editable=False, cellDescription=dict( cellType="Image" ) ), dict( identifier="textValue", title="Text", width=100, editable=True ), dict( identifier="popUpValue", title="PopUp", width=50, editable=True, cellDescription=dict( cellType="PopUpButton", cellClassArguments=dict( items=["A", "B", "C"] ) ) ), dict( identifier="sliderValue", title="Slider", width=50, editable=True, cellDescription=dict( cellType="Slider", cellClassArguments=dict( minValue=0, maxValue=1 ) ) ), dict( identifier="colorValue", title="Color", width=50, editable=True, cellDescription=dict( cellType="ColorWell" ) ), ] ) ) self.w = ezui.EZWindow( content=content, descriptionData=descriptionData, controller=self, size=(500, 200) ) def started(self): self.w.open() DemoController()
Description Data
items
The items to display in the table. Refer to the vanilla.List2 documentation for details about the types of items that are allowed.itemPrototype
A prototype item to be used with themakeItem
method. IfNone
is given, a prototype item will be derived from thecolumnDescriptions
.columnDescriptions
A list of column definition dictionaries. The key/value pairs are the same as the pairs defined in the vanilla.List2 documentation with some additions. These are the most frequently needed pairs:key
value
default
"identifier"
The unique identifier for this column.
required
"title"
The title to appear in the column header.
None
optional
"cellDescription"
A cell description dictionary.
A TextField cell.
optional
"editable"
Enable or disable editing in the column.
False
optional
"width"
The width of the column.
None
optional
"minWidth"
The minimum width of the column.
width
optional
"maxWidth"
The maximum width of the column.
width
optional
Cell Description Dictionary:
key
value
default
"cellType"
The cell type to use.
"TextField"
optional
"valueType"
The type of value allowed to be entered.
"string"
optional.
cellType
must be"TextField"
for this to be used."valueToCellConverter"
A function for converting object values to cell values.
function
optional.
"cellToValueConverter"
A function for converting cell values to object values.
function
optional.
"stringFormatter"
A string formatter function.
function
optional.
"valueFallback"
The value to store when the text can’t be converted to
valueType
.None
optional. Only used if the
valueType
is defined."valueListDelimiter"
The delimiter to use when breaking the value into lists.
" "
optional. Only used if the
valueType
is one of the"List"
options."cellClass"
The cell class to use.
None
optional
"cellClassArguments"
Arguments to use when creating the cell.
{}
optional
Cell Types:
"TextField"
"Slider"
"Checkbox"
"PopUpButton"
"Image"
"SegmentButton"
"ColorWell"
"LevelIndicator"
Cell Value Types:
"string"
"stringList"
"number"
"numberList"
"integer"
"integerList"
"float"
"floatList"
number, numberList, float and floatList default to rounding to three decimal places for display in the field. If you want more or less precision, add “:#” to the value type where “#” is an integer.
footer
A list of item descriptions defining items to place below the table.footer
should be formatted as thecontent
argument when creating a HorizontalStack. An additional
“gravity”` key may be used in the item descriptions to define where the item should align in the footer."leading"
"center"
"trailing"
insetFooter
If the footer should be inset.allowsGroupRows
If group rows are allowed. IfTrue
allowsSorting
will automatically be set toFalse
.drawFocusRing
If the focus ring should be drawn on the table.showColumnTitles
If the column titles should be shown.alternatingRowColors
If the rows have alternating colors.allowsSorting
If the table allows sorting by clicking column titles. This must beFalse
if group rows will be used.allowsSelection
If the table allows item selection.allowsMultipleSelection
If the table allows multiple selection.allowsEmptySelection
If the table allows empty selection.selectionCallback
The callback to call when an item is selected. Use the table’s identifier +"SelectionCallback"
as the expected callback name.doubleClickCallback
The callback to call when an item is double clicked. Use the table’s identifier +"DoubleClickCallback"
as the expected callback name.editCallback
The callback to call when an item is edited. Use the table’s identifier +"EditCallback"
as the expected callback name.dragSettings
See the vanilla.List2 documentation for thedragSettings
details.dropSettings
See the vanilla.List2 documentation for thedropSettings
details.- makeItem(**kwargs)
Make an item containing the necessary key/value pairs for the table by copying the
itemPrototype
given or derived during construction. Ifkwargs
are given, they will be set into the returned item.
- openPopoverAtIndex(popover, index)
Open the given
EZPopover
object near the row forindex
.
- getItem(index)
Get the item at
index
.
- setItem(index, item)
Set the
item
atindex
.
- insertItemsAtIndex(index, items)
Insert
items
atindex
.
- appendItems(items)
Append
items
to the end of the table’s contents.
- removeItemsAtIndexes(indexes)
Remove the items at
indexes
.
- removeSelectedItems()
Remove the selected items.
- setItemValue(index, identifier, value)
Set the
value
for the column withidentifier
in the item atindex
- getItemValue(index, identifier)
Get the value for the column with
identifier
in the item atindex
- get()
Get the list of items in the list.
- set(items)
Set the items in the list.
items should follow the same format as described in the constructor.
- reloadData(indexes=None)
Reload the data on display. This is needed when the items have changed values and the presentation of the items in the list needs to be updated.
indexes may be provided to indicate that only specific items need to be reloaded.
- getSelectedItems()
Get a list of selected items in the list.
- setSelectedItems(items)
Set the selected items in the list.
Note
setSelectedIndexes
is the recommended method for setting selection.setSelectedItems
is a convenience method that relies on iteration and comparing object ids to find the item indexes, which are then sent tosetSelectedIndexes
. If the list contains a large number of items this iteration can create a performance problem.
- getSelectedIndexes()
Get a list of indexes of selected items in the list.
- setSelectedIndexes(indexes)
Set the selected indexes in the list.
indexes should be a list of indexes.
- scrollToSelection()
Scroll the selected rows to visible.
- scrollToIndex(index)
Scroll the row to visible.
- enable(onOff)
Enable or disable the object. onOff should be a boolean.
- show(onOff)
Show or hide the object.
onOff A boolean value representing if the object should be shown or not.
- class ezui.FileTable
A table of files. This is a simplified version of :py:class:`Table`.
A file table is created with a line that starts with
|
, ends with|
and containsfiles
followed by an identifier.| files | @identifier
import ezui class DemoController(ezui.WindowController): def build(self): content = """ |-files----| @fileTable | | |----------| """ descriptionData = dict( fileTable=dict( itemType="dict", acceptedDropFileTypes=[".txt", ".md", ".fea"], allowsDropBetweenRows=True, allowsInternalDropReordering=True, columnDescriptions=[ dict( identifier="path", title="Path", cellClassArguments=dict( showFullPath=True ) ), dict( identifier="lines", title="Line Count" ) ] ) ) self.w = ezui.EZWindow( title="Demo", content=content, descriptionData=descriptionData, controller=self, size=(300, 300) ) def started(self): self.w.open() def fileTableCreateItemsForDroppedPathsCallback(self, sender, paths): items = [] for path in paths: with open(path, "r") as f: lines = len(f.read().splitlines()) item = dict( path=path, lines=lines ) items.append(item) return items DemoController()
Description Data
All of the description data of
Table
is allowed, except fordragSettings
anddropSettings
.acceptedDropFileTypes
The file types this table should accept from a drop. These must begin with a.
For example, `[“.designspace”, “.ttx”]acceptedDropPasteboardTypes
The accepted pasteboard types this table should accept from a drop. These can beNSPasteboardType
objects, vanilla values ("fileURL"
,"string"
,"plist"
). Custom pasteboard types are also allowed. If any values are given foracceptedDropFileTypes
"fileURL"
will be automatically added toacceptedDropPasteboardTypes
.itemType
The abstract type of item that the table will contain. The options are"object"
and “dict
“. This value instructs the table on how to get values from the item."object"
will use attributes and"dict"
will use the dict-like key/value model. If theitemType
is"object"
, each item must have apath
attribute. If theitemType
is"dict"
each item must have apath
key/value pair.columnDescriptions
The standard Table column desicriptions. There is a special column description that can be used to show the item’s path:dict( identifier="path", cellDescripion=dict( cellClassArguments=dict( showFullPath=False, truncationMode="middle" ) ) )
showFullPath
A boolean indicating if the full path should be shown or just the file name.truncationMode
A string indicating the preferred text truncation mode. The options are"clipping"
,"head"
,"tail"
,"middle"
.
allowsDropBetweenRows
A boolean indicating if dropping items between rows should honor the insertion point of the drop.allowsInternalDropReordering
A boolean indicating if the items in the table can be reordered with drag and drop.allowsDragOut
A boolean indicating if items in this table can be dragged and dropped somewhere else.createItemsForDroppedPathsCallback
The callback to be used when file pathss are dropped onto the table. This method must return items of the type defined initemType
. Use the table’s identifier +"CreateItemsForDroppedPathsCallback"
as the callback name.def myTableCreateItemsForDroppedPathsCallback(self, sender, paths): documents = [ OpenMyDocument(path) for path in paths ] return documents
makeDragDataCallback
The callback to be used to pack the items dragged out of the table. This must return a dictionary of form:{ pasteboard type : value}
where value must be a structure that can be stored in a plist. Use the table’s identifier +"MakeDragDataCallback"
as the callback name. This callback is optional and is only needed when creating custom data types.def myTableMakeDragDataCallback(self, sender, index): item = sender.get()[index] value = { "com.example.type.identifier" : item.asDict() }
filterItemsForImportCallback
The callback to be used when unpacking dropped items to be added to the table. This must return a list of items ready to be added to the table. Use the table’s identifier +"FilterItemsForImportCallback"
as the callback name. This callback is optional and is only needed in complex situations.def myTableMakeDragDataCallback(self, sender, availableDataTypes): items = availableDataTypes["com.example.type.identifier"] return items
- class ezui.FontTable
A table of fontParts fonts. This is a simplified version of :py:class:`FileTable`.
A font table is created with a line that starts with
|
, ends with|
and containsfonts
followed by an identifier.| fonts | @identifier
import ezui class DemoController(ezui.WindowController): def build(self): content = """ |-fonts----| @fontsTable1 | | |----------| |-fonts----| @fontsTable2 | | |----------| """ descriptionData = dict( fontsTable1=dict( items=AllFonts(), acceptedDropFileTypes=[".ufo"], allowsDropBetweenRows=True, allowsInternalDropReordering=True, allowsDragOut=True, height=200, columnDescriptions=[ dict( identifier="path", title="Path", cellDescription=dict( cellClassArguments=dict( showFullPath=True ) ) ), dict( identifier="name", title="Name" ) ] ), fontsTable2=dict( acceptedDropFileTypes=[".ufo"], allowsDropBetweenRows=True, allowsInternalDropReordering=True, height=200, columnDescriptions=[ dict( identifier="familyName", title="Family Name" ), dict( identifier="styleName", title="Style Name" ) ] ) ) self.w = ezui.EZWindow( content=content, descriptionData=descriptionData, controller=self, size=(500, "auto") ) def started(self): self.w.open() def fontsTable1CreateItemsForDroppedPathsCallback(self, sender, paths): fonts = [ OpenFont(path, showInterface=False) for path in paths ] return fonts def fontsTable2CreateItemsForDroppedPathsCallback(self, sender, paths): fonts = [ OpenFont(path, showInterface=False) for path in paths ] return fonts DemoController()
Description Data
All of the description data of
FileTable
is allowed, except foracceptedDropPasteboardTypes
.acceptedDropFileTypes
This lists contains the file types you wish to accept as paths. If you don’t want to accept unopened fonts, leave this list empty.columnDescriptions
The standard Table column desicriptions. There are a special column descriptions that can be used to show general font info:"path"
"name"
"familyName"
"styleName"
dict( identifier="name", )
If
allowsDragOut
isTrue
items dragged out of the table will be described on the “dev.robotools.fontParts.Font.Identifier” pasteboard. If you want to implement read/write on this pasteboard, the following protocols apply:fontParts Dragging Protocol
The data placed on the pasteboard will be the
id
of the wrapped defcon object. The dragging source will need to return the fontParts objects that wrap the objects with the given ids in thegetDropItemValues
method. For example:def getDropItemValues(self, items, pasteboardType=None): if pasteboardType == "dev.robotools.fontParts.Font.Identifier": idToFontParts = {id(obj.asDefcon()) : obj for obj in self.get()} fontPartsObjects = [] for item in items: wantedID = item.propertyListForType_(pasteboardType) fontPartsObjects.append(idToFontParts[wantedID]) return fontPartsObjects else: ...
If you have questions, contact the ezui developers.
- class ezui.TableGroupRow
A group row item.
text
The title of the group row. Optional.import ezui class DemoController(ezui.WindowController): def build(self): items = [ dict( cellType="TableGroupRow", text="ABC" ), "A", "B", "C", dict( cellType="TableGroupRow", text="XYZ" ), "X", "Y", "Z" ] windowContents = dict( type="Table", items=items, allowsGroupRows=True ) windowDescription = dict( type="Window", size=(300, 200), title="TableGroupRow", content=windowContents ) self.w = ezui.makeItem( windowDescription, controller=self ) def started(self): self.w.open() DemoController()
MerzView
- class ezui.MerzView
A MerzView. See the Merz documentation for details. MerzView Documentation.
To create a MerzView with a text description, use the item type name token
* MerzView
.import merz import ezui class DemoController(ezui.WindowController): def build(self): content = """ * MerzView @merzView """ descriptionData = dict( merzView=dict( backgroundColor=(1, 0, 0, 1), delegate=self ) ) self.w = ezui.EZWindow( title="Demo", content=content, descriptionData=descriptionData, size=(500, 500), controller=self ) merzView = self.w.getItem("merzView") merzContainer = merzView.getMerzContainer() merzContainer.appendOvalSublayer( position=("center", "center"), size=(450, 450), fillColor=(0, 0, 0, 0.25) ) self.brushLayer = merzContainer.appendBaseSublayer() def started(self): self.w.open() # Delegate Methods brushSize = 50 brushColor = (1, 1, 0, 0.25) def acceptsFirstResponder(self, sender): return True def mouseDown(self, sender, event): event = merz.unpackEvent(event) position = event["location"] self.brushLayer.appendOvalSublayer( position=position, size=(self.brushSize, self.brushSize), anchor=(0.5, 0.5), fillColor=self.brushColor ) def mouseDragged(self, sender, event): event = merz.unpackEvent(event) position = event["location"] self.brushLayer.appendOvalSublayer( position=position, size=(self.brushSize, self.brushSize), anchor=(0.5, 0.5), fillColor=self.brushColor ) def mouseUp(self, sender, event): self.brushLayer.clearSublayers() DemoController()
- getMerzContainer()
Return the merz container.
ScrollingMerzView
- class ezui.ScrollingMerzView
A ScrollingMerzView. See the Merz documentation for details. ScrollingMerzView Documentation.
To create a ScrollingMerzView with a text description, use the item type name token
* ScrollingMerzView
.- getMerzView()
Return the merz document view.
- getMerzContainer()
Return the merz container.
- getMerzViewSize()
Get the size of the merz document view.
- setMerzViewSize(size)
Set the size of the merz document view.
MerzCollectionView
- class ezui.MerzCollectionView
A MerzCollectionView. See the Merz documentation for details. MerzCollectionView Documentation.
To create a MerzCollectionView with a text description, use the item type name token
* MerzCollectionView
.
WebView
- class ezui.WebView
A web view. WebView usage reference.
To create a WebView with a text description, use the item type name token
* WebView
.import ezui testHTML = """ <html> <head> <style> body { background-color: red; color: white; font-family: "SF Pro"; text-align: center; } h1 { font-weight: 800; font-size: 100px; line-height: 1em; margin: 0; padding: 0; } h2 { font-weight: 100; font-size: 25px; line-height: 1em; margin: 0; padding: 0; } p { font-size: 15px; font-weight: 200; } </style> <script> function click1() { window.webkit.messageHandlers.text1.postMessage("You clicked One."); } function click2() { window.webkit.messageHandlers.text2.postMessage("You clicked Two."); } </script> <head> <body> <h1 onclick="click1()"> One </h1> <h1 onclick="click2()"> Two </h1> <p> Click the text above to trigger callbacks. </p> <h2 id="timeStamp"> </h2> </body> <html> """ class DemoController(ezui.WindowController): def build(self): content = """ * WebView @webView ==================== (Execute JavaScript) @executeJavaScriptButton """ descriptionData = dict( webView=dict( html=testHTML, handlers=[ "text1", "text2" ] ) ) self.w = ezui.EZWindow( content=content, descriptionData=descriptionData, size=(500, 500), controller=self ) def started(self): self.w.open() def text1Callback(self, sender, message): print(message) def text2Callback(self, sender, message): print(message) def executeJavaScriptButtonCallback(self, sender): import time js = f""" var e = document.getElementById("timeStamp"); e.innerText = "{time.strftime('%a, %d %b %Y %H:%M:%S')}"; """ webView = self.w.getItem("webView") webView.executeJavaScript(js) DemoController()
Description Data
html
HTML to be displayed.handlers
A list of handler identifiers. SeeaddHandlerIdentifier()
for details.- setHTML(html)
Set HTML in the view.
- setURL(url)
Set the url in the HTMLView.
- executeJavaScript(text)
Execute JavaScript within the html in the view.
- addHandlerIdentifier(identifier)
Add a handler identifier that will used to send messages to a callback from JavaScript within the HTML.
The
identifier
must be a string indicating the name of the handler to be used when sending messages back to your controller. Your controller must have a corresponding method with the nameidentifier + "Callback"
. Your JavaScript code should reference your identifier at the location noted bymyHandlerIdentifier
in this code:window.webkit.messageHandlers.myHandlerIdentifier.postMessage("A message,");
The message sent through
postMessage
can be any string.