To use this website fully, you first need to accept the use of cookies. By agreeing to the use of cookies you consent to the use of functional cookies. For more information read this page.

Official ZPE Programming Environment documentationUI Object

Introduction

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.

ZPEUI object functions

The following is a list of internal functions the ZPEUI 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.
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.

YASS
$gui = new ZPEUI()

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"))


  $gui->show()
  print("GUI created")

end function

function action()

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

end function
    

The generate_ui function

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

Comments

There are no comments on this page.

New comment
Reply
Provide feedback on this page
Comments are sent via email to me.