Monday 21 October 2019

arcgis desktop - python script tool validation checkboxes to radio boxes?


I am trying to build a tool in arcmap, which uses radio buttons in its gui. Since I read, that radio buttons are not supported, I figured, it couldn't be too hard changing the behaviour of simple boolean checkboxes, so that they act like actual radio buttons (no mutliple selections allowed).


So I went on and created three test parameters with datatype boolean. Next I added the following code to the tool validation function "def updateParameters" :


def updateParameters(self):
if self.params[0].value == True:

self.params[1].value = False
self.params[2].value = False

if self.params[1].value == True:
self.params[0].value = False
self.params[2].value = False

if self.params[2].value == True:
self.params[0].value = False
self.params[1].value = False

return

but it produces some odd behaviour: When I start out by selecting the third box (resp. set params[2] to true) and continue with clicking on the first checkbox, then the tool acts like it's supposed to (by unchecking params[2] and checking params[0]). But that's pretty much it. If I click the checkboxes in any different chronological order sometimes, two checkboxes can be set to true, sometimes no other than the active one can be clicked and so on.


Can anybody reproduce this error? Or maybe tell me what I do wrong?


I'm guessing when I check the first checkbox in the beginning, the other checkboxes are set to false until I uncheck it (which I could at least comprehend). But following that logic, why can I check the first box right after I checked the third one. Shouldn't the first one be also set to false and therefore be uncheckable?


Does anybody have an idea how to approach this?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...