Creating a Python optiSLang Application Wizard

The Python optiSLang Application Wizard (PyOWA) template allows you to define the web page view with Python commands. The pre-installed PyOWA Placeholder Table wizard is an instance of the common PyOWA wizard template. It contains the load_wizard.py Python script which describes the wizard view and behavior. The minimum script content is:

import pyowa

def app():
    page = pyowa.PageWizard('MyWizard')
    return page.to_json() 

This code defines an empty page with just the header MyWizard and can be extended with different objects.

The PyOWA Python module provides the following:

  • Containers to arrange objects like tables, lists, and sections

  • Static elements to enhance the user interface like a horizontal line, a label, or an image

  • Modifiable elements which can be changed by the user like numbers, check boxes, text, and so on

To start an optiSLang project the ProjectStarter object is available. The current values for all the modifiable objects are transferred to another Python script which is called by the ProjectStarter.

Example 5: Wizard Page Containing Two Labels, Two Numbers within a Table, and a ProjectStarter Object

import pyowa

def app():
    project_starter = pyowa.ProjectStarter('run_project.py', 'my_project.opf')

    table = pyowa.Table()
    table.append_child(0, pyowa.Label('m'))
    table.append_child(1, pyowa.Label('k'))
    table.append_child(0, pyowa.Number(1.))
    table.append_child(1, pyowa.Number(2.))

    section_table = pyowa.SectionHorizontalBordered('Values')
    section_table.set_margin_in_px(top=20)
    section_table.append_child(table)

    section_starter = pyowa.SectionHorizontalBordered('Start project')
    section_starter.set_margin_in_px(top=20)
    section_starter.append_child(project_starter)

    page = pyowa.PageWizard('MyWizard')
    page.append_child(section_table)
    page.append_child(section_starter)

    return page.to_json()