Jamie Balfour

Welcome to my personal website.

Find out more about me, my personal projects, reviews, courses and much more here.

Official ZPE/YASS documentationUIBuilder object

Official ZPE/YASS documentationUIBuilder object


ZPE 1.6.7 (November 2018) added the UI object, a built-in object that allows user interfaces (UIs) to be generated and displayed. It uses the underlying Java Swing/AWT libraries for user interfaces.

UIBuilder object functions

The following is a list of internal functions the UIBuilder object exposes. All functions are ZPEObjectNativeFunctions unless specified therefore run in native code.

alert (string text) ⇒ boolean
Displays a message to the user using the UI alert box.
show () ⇒ string
Displays the current UI object on the display.
hide () ⇒ string
Hides the current UI object from the display.
get_element_by_id (string id) ⇒ object
Gets an element using its ID. The ID must be set on the element using the set_element object function.
set_on_close (boolean value) ⇒ void
Determines whether the program loop should stop when the window is closed.
create_button (string text) ⇒ string
Creates a new button on the GUI with the text, text.

Examples in action

The following example creates a simple GUI with two buttons, each with events attached to them.


$gui = new UIBuilder()

function main()

  $b1 = $gui->create_button("Test button")
  $b1->on("click", function(){
    $gui->alert("Button 1 clicked")
  $b1->set_text("Test button 1")

  $b2 = $gui->create_button("Test button 2")
  $b2->on("click", handle_of("action"))

  print("GUI created")

end function

function action()

  $gui->alert("Button 2 clicked")

end function

One of the projects I have been working myself is a home automation program. As such I use ZPE/YASS to do this since it gives more power over many other languages. I use the UIBuilder to make it easy to run these programs. For example I have an option to wake and shutdown my PC. You can find my home automation program on my ZPE Online account.

The generate_ui function

The built-in generate_ui function generates a new UIBuilderObject object. This can be stored in a variable and referenced later using the object syntaxes.

Feedback 👍
Comments are sent via email to me.