1

How do I add values (items) in a list widget in IntraMaps Roam (2.3.1 release)?

I'm trying to add values (items) to a list widget in a form with Python code (ver. 3.3.2) I have created the form and added attributes and controls (widgets?) in the Roam manager. The items in a list no. 2 (veg1-2) depend on which item is selected in a list no. 1 (veg1-1).

(I have manged to base the populating of list no. 2 on the selected item in list no. 1 in QGIS ver. 2.6.1 by modifying the code I found here: How to automatically populate fields instantly?).

I would like to implement something similar in __init__.py of the form (Test) in my project (Vegetasjonstest) created in Roam Manager.

I have read the Roam's "wiki", but how do I code

self.boundwidgets['veg1-2'].setvalue(…)

correctly so that veg1-2 list is populated with items?

From my C:\IntraMaps Roam\projects\Vegetasjonstest\Test\__ini__.py file (aere I'm using a change in a text widget "anna1" to change the value of another text widget "tre1" (this works fine) while changing the item in the list widgets fails, i.e. nothing happens. However, the showpopup functions works. Just using it as a test.):

def uisetup(self):
    """
    Called when the UI is fully constructed.  You should connect any signals here.
    """
    self.boundwidgets['anna1'].valuechanged.connect(self.handler)
    pass

def handler(self, value):
    liste1 = ['a','b','c']
    if ( self.boundwidgets['anna1'].value() == "b" ):
        self.boundwidgets['veg1-2'].setvalue("blomst ; blume")
        # self.boundwidgets['veg1-2'].showpopup()
        self.boundwidgets['tre1'].setvalue("Gran")

I have tried several ways like e.g.

self.boundwidgets['veg1-2'].setvalue("blomst")
self.boundwidgets['veg1-2'].setvalue("a,b,c")
self.boundwidgets['veg1-2'].setvalue(liste1)

without any luck.

1 Answer 1

1

You will need something like this:

def uisetup(self):
    """
    Called when the UI is fully constructed.  You should connect any signals here.
    """
    self.boundwidgets['anna1'].valuechanged.connect(self.handler)
    pass

def handler(self, value):
    liste1 = ['a','b','c']
    if ( value == "b" ):
        self.boundwidgets['veg1-2'].config = dict(list=dict(items=liste1))
        self.boundwidgets['tre1'].setvalue("Gran")

Provided liste1 is what you want to show in the veg1-2 list

1
  • The solution of @Nathan works like a charm, thanks!
    – 9ls1
    Jan 15, 2015 at 9:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.