Skip to content

Commit 6750c6a

Browse files
author
Randy Heiland
committed
optional new features
1 parent 4b3d7a5 commit 6750c6a

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

bin/config.py

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
class ConfigTab(object):
1010

11-
def __init__(self):
11+
# def __init__(self):
12+
def __init__(self, xml_root):
1213

1314
# micron_units = HTMLMath(value=r"$\mu M$")
1415
micron_units = Label('micron') # use "option m" (Mac, for micro symbol)
@@ -268,16 +269,28 @@ def toggle_cells_csv_cb(b): # why can't I disable this widget?!
268269

269270

270271
# domain_box = VBox([label_domain,x_row,y_row,z_row], layout=box_layout)
271-
domain_box = VBox([label_domain,x_row,y_row, self.toggle_virtual_walls], layout=box_layout)
272-
self.tab = VBox([domain_box,
272+
uep = xml_root.find(".//options//virtual_wall_at_domain_edge")
273+
if uep:
274+
domain_box = VBox([label_domain,x_row,y_row, self.toggle_virtual_walls], layout=box_layout)
275+
else:
276+
domain_box = VBox([label_domain,x_row,y_row], layout=box_layout)
277+
278+
uep = xml_root.find(".//options//virtual_wall_at_domain_edge")
279+
if uep:
280+
self.tab = VBox([domain_box,
273281
HBox([self.tmax, Label('min')]), self.omp_threads,
274282
svg_mat_output_row,
275283
label_blankline,
276284
# HBox([self.csv_upload.w, self.toggle_cells_csv]),
277285
upload_cells_hbox,
278286
# HBox([self.substrate[3], self.diffusion_coef[3], self.decay_rate[3] ]),
279-
]) # output_dir, toggle_2D_seed_
280287
# ], layout=tab_layout) # output_dir, toggle_2D_seed_
288+
])
289+
else:
290+
self.tab = VBox([domain_box,
291+
HBox([self.tmax, Label('min')]), self.omp_threads,
292+
svg_mat_output_row,
293+
])
281294

282295
# Populate the GUI widgets with values from the XML
283296
def fill_gui(self, xml_root):
@@ -293,7 +306,8 @@ def fill_gui(self, xml_root):
293306
self.zmax.value = float(xml_root.find(".//z_max").text)
294307
self.zdelta.value = float(xml_root.find(".//dz").text)
295308

296-
if xml_root.find(".//options//virtual_wall_at_domain_edge").text.lower() == 'true':
309+
uep = xml_root.find(".//options//virtual_wall_at_domain_edge")
310+
if uep and (uep.text.lower() == 'true'):
297311
self.toggle_virtual_walls.value = True
298312
else:
299313
self.toggle_virtual_walls.value = False
@@ -316,13 +330,15 @@ def fill_gui(self, xml_root):
316330
self.toggle_svg.value = False
317331
self.svg_interval.value = float(xml_root.find(".//SVG//interval").text)
318332

319-
# if xml_root.find(".//initial_conditions//cell_positions").text.lower() == 'true':
320-
if xml_root.find(".//initial_conditions//cell_positions").attrib["enabled"].lower() == 'true':
321-
self.toggle_cells_csv.value = True
322-
else:
323-
self.toggle_cells_csv.value = False
333+
# if xml_root.find(".//initial_conditions//cell_positions").attrib["enabled"].lower() == 'true':
334+
uep = xml_root.find(".//initial_conditions//cell_positions")
335+
if uep:
336+
if uep.attrib["enabled"].lower() == 'true':
337+
self.toggle_cells_csv.value = True
338+
else:
339+
self.toggle_cells_csv.value = False
324340

325-
self.toggle_cells_csv.description = xml_root.find(".//initial_conditions//cell_positions//filename").text
341+
self.toggle_cells_csv.description = xml_root.find(".//initial_conditions//cell_positions//filename").text
326342

327343

328344
# Read values from the GUI widgets and generate/write a new XML
@@ -353,7 +369,10 @@ def fill_xml(self, xml_root):
353369
xml_root.find(".//full_data").find(".//interval").text = str(self.mcds_interval.value)
354370

355371
# uep.find('.//cell_definition[1]//phenotype//mechanics//options//set_absolute_equilibrium_distance').attrib['enabled'] = str(self.bool1.value)
356-
xml_root.find(".//initial_conditions//cell_positions").attrib["enabled"] = str(self.toggle_cells_csv.value)
372+
# xml_root.find(".//initial_conditions//cell_positions").attrib["enabled"] = str(self.toggle_cells_csv.value)
373+
uep = xml_root.find(".//initial_conditions//cell_positions")
374+
if uep:
375+
uep.attrib["enabled"] = str(self.toggle_cells_csv.value)
357376

358377
# user_details = ET.SubElement(root, "user_details")
359378
# ET.SubElement(user_details, "PhysiCell_settings", name="version").text = "devel-version"

bin/tool4nanobio.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
tree = ET.parse(full_xml_filename) # this file cannot be overwritten; part of tool distro
4949
xml_root = tree.getroot()
5050

51+
config_tab = ConfigTab(xml_root)
5152
microenv_tab = MicroenvTab()
5253
user_tab = UserTab()
5354

0 commit comments

Comments
 (0)