Wiki
Clone wikins-xml / program / XULTutorial
Creating a XUL application
This tutorial will demonstrate how to use the program interface definition framework to create a XUL application frountend to a command line program.
Prerequisites
We assume you understood the basis of the program interface definition framework and read one of the tutorial to build a command line program.
To run the generated XUL application, the target system needs a XUL interpreter.
- For Linux
- Firefox (version >= 4) - Recommended
- or xulrunner standalone binary (version >= 2)
In any case, the binary have to be located in one of the path specified by the PATH
environment variable.
- For Mac OS X
- XUL.framework (version >= 6) - Recommended
- or Firefox (version >= 4)
The XUL.framework have to be installed in a standard location
(
/Library/Frameworks
or${HOME}/Library/Frameworks
) or copied inside the application bundle (not recommended)
Firefox have to be installed in the /Applications
folder.
Even if Firefox can be used as a XUL interpreter, the application will not run perfectly well:
- The application icon will be the Firefox icon
- The main Mac OS X menu will not work properly
Step 1. Defining the command line program
- Follow step 1 to 3 of the UNIX shell tutorial to build a XUL frontend over your own shell script built with the program interface definition framework
- Follow step 1 and 2 of the Python tutorial to build a XUL frontend over your own Python script built with the program interface definition framework
- Follow step 1 of any of these tutorials to build a XUL frontend over an existing command (Describe the options you want to map in the XUL frontend)
Step 2. Customize the GUI (optional)
The application behavior and the main window UI can be changed at runtime using Javascript.
At start, the application loads a specific Javascript file and look for a onInitialize()
function. This entry point can be used
to tweak the standard look & feel of the generated frontend by replacing, removing or adding elements.
- See the XUL Javascript API for implementation details.
- See the next step to learn how to specify which Javascript file to include in your XUL frontend.
Step 3. Build the application
For auto-generated shell scripts
${NSXML_PATH}/ns/sh/build-xulapp.sh shell -s ${xshFilePath} -o ${outputFolder}
For auto-generated Python scripts
${NSXML_PATH}/ns/sh/build-xulapp.sh python -p ${pythonScriptPath} -x ${xmlOptionDescriptions}
For existing commands
${NSXML_PATH}/ns/sh/build-xulapp.sh cmd -c ${commandName} -x ${xmlOptionDescriptions}
See also
The build-xulapp documentation for more details and options.
Step 5. Run
Linux
Execute the script file located at the root of the application folder generated in step 3. It's name depends of the <name />
node value in the XML program description file.
Mac OS X
Open the application bundle generated in step 3
Updated