This example, like most LGUI2 examples, consists of a controller object in LavishScript (in 1.iss) and a LavishGUI 2 package file (1.json)
Run the script with run lern/lgui2/1
.
When this script runs, the LavishGUI 2 package file will be loaded via LGUI2:LoadPackage[filename]
, producing a window with the content "Hello World!"
This script will remain running until specifically ended, even if the window is closed by clicking its close button. End the script with end 1
when finished; the full path is not required.
When the script is ended, the LavishGUI 2 package file will be unloaded via LGUI2:UnloadPackage[filename]
, and thereby removing the window that was loaded.
A LavishGUI 2 Package is a JSON object that can contain a list of UI elements, and other related data.
A $schema
property is specified in order to have validation, tooltips and auto-complete while editing the JSON.
"$schema": "http://www.lavishsoft.com/schema/lgui2Package.json",
An elements
array will specify each of the root-level GUI elements to create when this package is loaded.
"elements": []
In this example, we create a window with a small handful of properties.
{
"$schema": "http://www.lavishsoft.com/schema/lgui2Package.json",
"elements": [
{
"type":"window",
"title":"LGUI2 Example 1",
"name": "example1.window",
"content":"Hello World!",
"width":200,
"height":60
}
]
}
Most of these properties are optional, however type
must always be provided, and for UnloadPackage
to destroy the UI elements, a name
must be provided.
This is still a valid UI element that can be unloaded via UnloadPackage
:
{
"type":"window",
"name": "example1.window"
}
It is also worth noting that LavishGUI 2 elements can also be represented by a string, instead of by a JSON Object. Here, content
is actually accepting a UI element definition, which we have given as "Hello World!"
. Any element defined as a string instead of a JSON object will automatically be a textblock
element, defined like so:
{
"type":"textblock",
"text":"Hello World!"
}
-
Change the
content
text, and run the example again -
Change the
content
to a JSON object that defines atextblock
, instead of just a string -
Did we mention that
title
is also a UI element? Change thetitle
to a JSON object that defines atextblock
, instead of just a string -
Create your own LavishGUI 2 Package .json file with a
window
, and a .iss file toLoadPackage
andUnloadPackage
- LavishGUI 2 Package: https://www.lavishsoft.com/wiki/index.php/LGUI2:Package
- LavishGUI 2 Elements: https://www.lavishsoft.com/wiki/index.php/LGUI2:Elements
window
element: https://www.lavishsoft.com/wiki/index.php/LGUI2:windowtextblock
element: https://www.lavishsoft.com/wiki/index.php/LGUI2:textblock