Skip to content

Commit a51515e

Browse files
iorhanVjmcouffin
authored andcommitted
Adding exitscript option to SelectFromList from pyrevit.forms
1 parent cf7ad19 commit a51515e

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

pyrevitlib/pyrevit/forms/__init__.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,8 @@ class SelectFromList(TemplateUserInputWindow):
804804
object attribute that should be read as item name.
805805
multiselect (bool, optional):
806806
allow multi-selection (uses check boxes). defaults to False
807+
exitscript (bool, optional):
808+
exit if close or nothing is returned. defaults to False
807809
info_panel (bool, optional):
808810
show information panel and fill with .description property of item
809811
return_all (bool, optional):
@@ -902,6 +904,9 @@ def _setup(self, **kwargs):
902904
self.list_lb.SelectionMode = Controls.SelectionMode.Single
903905
self.hide_element(self.checkboxbuttons_g)
904906

907+
# exitscript
908+
self.exitscript = kwargs.get('exitscript', False)
909+
905910
# info panel?
906911
self.info_panel = kwargs.get("info_panel", False)
907912

@@ -1181,6 +1186,24 @@ def clear_search(self, sender, args): # pylint: disable=W0613
11811186
self.search_tb.Clear()
11821187
self.search_tb.Focus()
11831188

1189+
@classmethod
1190+
def show(cls, context, #pylint: disable=W0221
1191+
title='User Input',
1192+
width=DEFAULT_INPUTWINDOW_WIDTH,
1193+
height=DEFAULT_INPUTWINDOW_HEIGHT, **kwargs):
1194+
"""Show user input window.
1195+
1196+
Args:
1197+
context (any): window context element(s)
1198+
"""
1199+
dlg = cls(context, title, width, height, **kwargs)
1200+
dlg.ShowDialog()
1201+
1202+
if dlg.exitscript and not dlg.response:
1203+
sys.exit()
1204+
1205+
return dlg.response
1206+
11841207

11851208
class CommandSwitchWindow(TemplateUserInputWindow):
11861209
"""Standard form to select from a list of command options.

0 commit comments

Comments
 (0)