Overview
Basics of a form
An application is defined as a namespace containing several main functions with predefined names (starting with gui
) and syntax. These are described in the table below.
For Python the namespace must be a module. For MATLAB it must be a package.
Simian GUI must be able to find the namespace on the path. Refer to the examples for illustrations.
Simian GUI will try to execute the gui
functions during initialization and when handling events.
The form code can be in other files and functions, as long as the gui
functions call these other functions in turn.
When the functions are not found or cannot be executed for any other reason, the form will not function correctly.
gui functions
Function | Description |
---|---|
payload = gui_init(metadata) | Required: Form initialization code. See Form definition. |
payload = gui_event(metadata, payload) | Required: Event handling code. See Handling events. |
payload = gui_download(metadata, payload) | Optional: Download content from the form. This function is executed instead of gui_event when the downloadStart event is triggered. For more information, see the gui_download section. |
payload = gui_upload(metadata, payload) | Optional: Upload content to the form. This function is executed instead of gui_event when a button is clicked that had the setUpload method called on it during form initialization. For more information, see the gui_upload section. |
gui_close(metadata) | Optional: Define what should happen when the application is closed. For example, data may need to be saved or the workspace might need to be cleaned up. In addition to what is executed in your custom function, the cache is cleared. |
gui_refresh() | Optional, Python only: Called when using the Form refresh button for fast re-initialization during development. |
Note that the snake case gui_xxx
functions have a lower camel case guiXxx
equivalent in the MATLAB version of Simian GUI.
Running locally
The functions must be in a package (or module) to prevent shadowing these functions implemented for other potential applications created with Simian GUI. Once these functions have been created and the code and Simian are on the path, the form can be initialized locally by using:
import simian.local
simian.local.Uiformio("my.namespace")
simian.local_v3_0_1.Uiformio("my.namespace")
where "my.namespace"
is the unique namespace of your form.
The following extra options can be specified:
- Python:
Uiformio(_, debug=debug)
Sets the application debug flag.Uiformio(_, fullscreen=fullscreen)
Sets the window full screen on start when true.Uiformio(_, size=size)
Sets the initial window size [width, height].Uiformio(_, window_title=window_title)
Specifies a title for the application window.Uiformio(_, show_refresh=True)
Shows the Refresh button in the navbar.
- MATLAB:
Uiformio(_, "FigureHandle", figHandle)
Specifies a custom parent figure.Uiformio(_, "FigureProps", props)
Specifies additional options (cell array) to use for the uihtml component.Uiformio(_, "Fullscreen", fullscreen)
Sets the figure full screen on start when true.Uiformio(_, "Maximized", maximized)
Maximizes the figure on start when true.Uiformio(_, "Size", size)
Sets the initial size [width, height] of the figure.Uiformio(_, "WindowTitle", title)
Specifies a title for the figure.Uiformio(_, "ShowRefresh", true)
Shows the Refresh button in the navbar.
For deploying the form on a server please refer to the deployment chapter.