My ArcMap (10.5.1) Python add-in uses a combobox. When an item is selected from the combobox's drop-down menu, the expected actions are executed successfully. Sometimes these actions actions can take some time to complete, and sometimes some further UI is required (in the simplest case, a progress dialogue). The problem is that the combobox's drop-down menu remains visible on screen during this time and can partially or completely obscure whatever subsequent UI is displayed.
I would like the combobox to be dismissed as soon as I make the selection (eg, at the beginning of onSelChange()
).
How can I force the combobox's drop-down menu to disappear immediately after an item has been selected?
The combobox will disappear as soon as I interact with anything else on screen (outside of the combobox). But this is not really sufficient and results in a terrible UI.
Below is the minimal add-in code that demonstrates the issue for a combo-box:
import arcpy, pythonaddins, time
class TestComboBox(object):
"""Implementation for TITest_addin.TestComboBox (ComboBox)"""
def __init__(self):
self.items = ["Item {}".format(i) for i in range(100)]
self.editable = False
self.enabled = True
self.dropdownWidth = 30 * 'W'
self.width = 10 * 'W'
def onSelChange(self, selection):
with pythonaddins.ProgressDialog() as prog:
prog.title = "This is a test."
prog.animation = "Spiral"
prog.canCancel = False
time.sleep(10)
def onEditChange(self, text):
pass
def onFocus(self, focused):
pass
def onEnter(self):
pass
def refresh(self):
pass
UPDATE:
I think that any combobox add-in with self.editable = False
may exhibit the same problem. Merely changing that line to self.editable = True
fixes the issue. However, having self.editable = True
is not an option for my add-in.
I have logged this issue with ESRI now, and will post back here if I get any useful information from them.