The functionality provided by GUIKit has been superseded by the interface construction and controls functions native to the built-in Wolfram Language.

Widget Basics

Widgets are the basic component of GUIs built with GUIKit. This tutorial discusses some of the basics of widgets and how they work. More detailed information on widgets can be found in "Definition Building Blocks".

This creates a basic widget that consists of a panel with three buttons. It does not display anything yet.

This runs the widget; now you should see the panel appear on your screen.

The result of GUIRun is a GUIObject expression; this can be used as a handle to the executing GUI.

GUIScreenShot takes a GUIObject expression and returns a picture that shows how the GUI appears on screen. The image you see may be more appropriate for your system.

Widget Naming

One of the key features of GUIKit is that you can give widgets names.

This creates and runs a widget, and it gives it a name.

GUIInformation takes a GUIObject expression and returns information about its internals. This example extracts all the named widgets from the GUIObject. There is only one name: MyWidget.

Widget names will be used in many places for scripting GUIs.

Widget Properties

Manipulation of widgets through their properties is a key concept of GUIKit. There are a number of property-based functions that aid in discovering what properties exist on widgets in an interface and also querying and modifying their current values.

This runs a GUI that has two named widgets.

This shows that there are two named widgets.

This requests a list of all property names available with the widget referred to by "button1" in the dialog.

You can use ToString and ToExpression with SetPropertyValue to include conversion to String or Wolfram Language expression values, using common optional arguments found with ToString and ToExpression. This changes the text property, and the new value shows up immediately.

The property value can be extracted directly from the widget reference.

This shows that the property value that was returned is a string.

Property values that automatically have equivalent Wolfram Language expressions as defined by J/Link can be returned or set using the standard PropertyValue function.

Further Widget Details

In addition to names and properties, widgets have a number of other details that are important for creating GUIs. These can be investigated using the GUIObject reference.

This runs a built-in GUI.

This shows a dynamic snapshot of the interface.

You can retrieve a list of all widgets in the interface that have been registered with unique string names and reference these widget instances by these reference names.

This discovers all property names available with the widget registered with the name "inputField". You can query and set these values using PropertyValue[{"inputField","propertyName"}] and SetPropertyValue[{"inputField","propertyName"},newValue].

You can also find out what method names exist that can be executed on this widget with InvokeMethod[{"inputField","methodName"},arguments] and even filter these names using string patterns.

Additionally, you can discover what event names can be used to cause Wolfram Language code to execute whenever the event occurs by using BindEvent[{"inputField","eventName"},Script[code]].