Skip to content

Commit

Permalink
Added hdnling for boolean control parameters for jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
paulsaxe committed Nov 15, 2023
1 parent 24dc3fc commit 7eae77d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
7 changes: 4 additions & 3 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
=======
History
=======
2023.11.15 -- Bugfix: running flowcharts from the commandline.
* The previous change to allow running "flowchart.flow" in the current directory
caused a bug in other scenarios.
2023.11.15 -- Add boolean options when submitting jobs
* Added boolean control parameters when submitting jobs.
* Bugfix: The previous change to allow running "flowchart.flow" in the current
directory caused a bug in other scenarios.

2023.11.12 -- Allowing running flowchart.flow in current directory
* There was a feature which prevented running a flowchart named "flowchart.flow" in
Expand Down
37 changes: 29 additions & 8 deletions seamm/tk_job_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def __init__(self, root=None):
self._flowchart = None
self._widgets = {}
self._variable_value = {}
self._tk_var = {} # For checkbuttons
self.resource_path = Path(pkg_resources.resource_filename(__name__, "data/"))

s = ttk.Style()
Expand Down Expand Up @@ -810,14 +811,29 @@ def submit_with_dialog(self, flowchart):
d.rowconfigure(7, weight=1)
row = 0
for step in parameter_steps:
variables = step.parameters["variables"]
for name, data in variables.value.items():
variables = {**step.parameters["variables"].value}
for name, data in variables.items():
table[row, 0] = name
if name not in value or value[name] is None:
value[name] = data["default"]
entry = ttk.Entry(frame)
entry.insert(0, value[name])
table[row, 1] = entry
table[row, 0].grid(sticky=tk.E)
if data["type"] == "bool":
if name not in value or value[name] is None:
value[name] = False
var = self._tk_var[name] = tk.IntVar()
checkbox = ttk.Checkbutton(frame, variable=var)
var.set(1 if value[name] else 0)
table[row, 1] = checkbox
else:
if name not in value or value[name] is None:
value[name] = data["default"]
if len(data["choices"]) > 0:
combo = ttk.Combobox(frame, values=data["choices"])
combo.set(value[name])
combo.configure(state="readonly")
table[row, 1] = combo
else:
entry = ttk.Entry(frame)
entry.insert(0, value[name])
table[row, 1] = entry
table[row, 1].grid(sticky=tk.EW)
if data["type"] == "file":
button = tk.Button(
Expand Down Expand Up @@ -845,7 +861,12 @@ def submit_with_dialog(self, flowchart):
table = self["parameters"]
for row in range(table.nrows):
name = table[row, 0].cget("text")
value[name] = table[row, 1].get()
data = variables[name]
if data["type"] == "bool":
tmp = self._tk_var[name].get()
value[name] = True if tmp == 1 else False
else:
value[name] = table[row, 1].get()

dashboard_name = result.pop("dashboard")
dashboard = self.dashboard_handler.get_dashboard(dashboard_name)
Expand Down

0 comments on commit 7eae77d

Please sign in to comment.