User Panels

Each user panel must have an open function, containing the menu definitions, and a call to TreeItem(), to place an item on the Data Tree and hook it up to the panel function. In addition, it may contain any number of supporting functions and operations, including data initialization.

All user function names must start with usr. It is also recommended that the name is followed by its action, such as Open, and the panel name.

The structure of a panel open function is as follows:
def usrOpenXXX( item, args ):
      node = ROOT + RS + 'User' + RS + 'XXX'
      MenuInt( name = 'Menu Label',
               tooltip = 'This is the tooltip/bubble info',
               whatsthis= 'This is the whatsthis extended info',
               helpURL = 'pointer to an html help file',
               node = node,
               par = 'parameter name',
               redraw = False,
               default = 1 )
      MenuStr( name = 'Second Menu Label', ... )
And it is hooked to the Data Tree by the following call:
TreeItem( parent = UsrHead,
          name = 'Panel Name',
          tooltip = 'This is the tooltip/bubble info',
          whatsthis= 'This is the whatsthis extended info',
          helpURL = 'pointer to an html help file',
          popup = (( 'Open', usrOpenXXX ),),
          click2 = 'Open' )

Here XXX is the name of the panel, such as StaticMixer.

The parameters of this panel are stored under the database node given by the node variable. All database nodes are defined relative to the ROOT; and RS is its record separator. You can think of the database as a file system, with nodes as its directories, RS as the directory separator, '/', and parameters as files. In the above example, the node variable is set to the directory /User/XXX, containing the panel parameters. The top level directory User is reserved for user specific data, as such, it is safe to be used as desired.

An open function may contain any number of menus. Each menu displays a label, followed by a widget to obtain user input. AcuConsole provides a rich set of menus:
An on/off boolean menu
An integer menu
A floating point menu
A string menu
An enumerated menu, select from a list
An enumerated menu, referencing a DB node child
An array of floating point numbers menu
An array of strings menu
An array of references menu
A push button menu which executes a function
A menu to provide selection tabs
A simple information menu (no user input)

The above MenuInt() example contains the list of arguments common to all but MenuFunc, MenuTab and MenuInfo menus, which are special menus. Each menu type may also have other arguments; see the specific function definition for full description.

In short, each menu has a name, which is displayed as its label; three help arguments: tooltip, whatsthis and helpURL, as described above for TreeItem(); database node location and par name; default value, in case the par does not already exist; and the redraw flag, which if true will force redraw of the panel upon change.

The value displayed in the menu is extracted automatically from the database, and upon change by you, it is placed back into the database. When the menu is first executed, the database is checked for value, if there is no par defined, it is initialized by the default value.

The database values may be extracted using the Get functions: GetBool, ..., GetRefs; and updated using the Put functions: PutBool, ..., PutRefs.

Again, an item is added to the Data Tree using the TreeItem() function. The open function is hooked to this item via the popup argument. This argument accepts a tuple of tuples (list of lists). For each inner tuple, an item is added to the right-click popup of tree item. Its name is extracted from the first value of the inner tuple, while the second entry is the function to be executed, and all additional entries are collected and passed as args to the function. The click2 argument may be used to hook double click on the tree item to an entry in the popup.

Finally, note that Python is a general purpose language, with a very rich set of functionality and capabilities, both built-in and as external extensions. Therefore, in principal you can write as complex of panel definition as desired.