![]() | Defining the GUI |
| Prev | Next |
Table of Contents
In the previous chapter you've seen how to register a plugin with RKWard. The most important ingredient was specifying the path to an XML file with a description of what the plugin actually looks like. In this chapter you'll learn how to create this XML file.
After reading this chapter, have a look at the rkwarddev package as well. It provides some R functions to create most of RKWard's XML tags for you.
Once again we'll walk you through an example. The example is a (slightly simplified) version of the two variable t-Test.
<!DOCTYPE rkplugin>
The doctype is not really interpreted, yet. Set it to rkplugin, anyway.
<document> <code file="t_test_two_vars.js"/>
All plugins generate some code. Currently the only way to do so is using JS, as detailed in the next chapter. This defines, where to look for the JS code. The filename is relative to the directory the plugin XML is in.
<help file="t_test_two_vars.rkh"/>
It is usually a good idea to also provide a help page for your plugin. The filename of that help page is given, here, relative to the directory, the plugin XML is in. Writing help pages is documented here. If you do not provide a help file, omit this line.
<dialog label="Two Variable t-Test">
As you know, plugins may have either a dialog or a wizard interface or both. Here we start definining a dialog interface. the label attribute specifies the caption of the dialog.
<tabbook> <tab label="Basic settings">
GUI elements can be organized using a tabbook. Here we define a tabbook as the first element in the dialog. Use <tabbook>[...]</tabbook> to define the tabbook and then for each page in the tabbook use <tab>[...]</tab>. The label attribute in the <tab> element allows you to specify a caption for that page of the tabbook.
<row id="main_settings_row">
The <row> and <column> tags specify the layout of the GUI elements. Here you say, that you'd like to place some elements side-by-side (left to right). The id attribute is not strictly necessary, but we'll use it later on, when adding a wizard interface to our plugin. The first element to place in the row, is:
<varselector id="vars"/>
Using this simple tag you create a list from which the user can select variables. You have to specify an id for this element, so RKWard knows how to find it.
You may NOT use a dot (.) in the id string.
<column>
Next, we nest a <column> inside the row. I.e. the following elements will be place above each other (top-to-bottom), and all will be to the right of the <varselector>.
<varslot types="number" id="x" source="vars" required="true" label="compare"/> <varslot types="number" id="y" source="vars" required="true" label="against"/>
These elements are the counterpart to the <varselector>. They represent “slots” into which the user can put variables. You will note that the source is set to the same value as the id of the <varselector>. This means, the <varslot>s will each take their variables from the varselector. The <varslot>s also have to be given an id. They may have a label, and they may be set to required. This means that the