Python for form creation

Hi all,

I'm wondering if anyone out there is building forms directly from Python. I've been working on a particularly complex form in xlsforms, and I've been missing a good few Python features whilst flapping around in Excel.

I can see a Python/Pandas > Excel > pyxform > XML workflow, but I'm wondering if anyone's doing anything different. The pyxform documentation's pretty limited, I imagine however that one could probably work straight from there?

You could mimic the basic structure of the XLSForm in a JSON structure and pass it through to pyxform. We do something similar in kobo's formpack.

It's not well documented. But here's an example written in python that uses the function i linked to:

from formpack.utils.xform_tools import formversion_pyxform

pyxform_survey = formversion_pyxform({
    'survey': [
        {'type': 'text',
        'name': 'q1',
        'label': 'text question'},
        {'type': 'select_one colors',
        'name': 'color',
        'label': 'color'}
    ],
    'choices': [
        {'list_name': 'colors', 'value': 'red', 'label': 'Red'},
        {'list_name': 'colors', 'value': 'blue', 'label': 'Blue'},
    ],
    'settings': {'id_string': 'simple',
                 'title': 'simple example xform',
                 'name': 'data'}
})

print(
    pyxform_survey.to_xml()
    )

Perfect, that's exactly what I was looking for, and makes complete sense. Looking forward to trying it out. I'm pretty much done with the form I'm working on now, but will give it a go next time. I'll try to document if I have the space.

Hi Alex,

How can i install "formpack.utils.xform_tools" package? Could you assist me?

Thank you!