From 6b41badea889c8662a571c4fd1496da73e306555 Mon Sep 17 00:00:00 2001 From: keenanlang Date: Mon, 29 Jul 2024 17:25:45 -0500 Subject: [PATCH] Pass along naming conventions --- gestalt/Node.py | 15 ++++++++++++++- gestalt/convert/phoebus/CSSGenerator.py | 2 ++ gestalt/convert/phoebus/CSSWidget.py | 8 ++++++++ gestalt/convert/qt/QtGenerator.py | 6 ++++-- gestalt/convert/qt/QtWidget.py | 9 ++++++++- 5 files changed, 36 insertions(+), 4 deletions(-) diff --git a/gestalt/Node.py b/gestalt/Node.py index 7151b97..c2b0506 100644 --- a/gestalt/Node.py +++ b/gestalt/Node.py @@ -580,6 +580,9 @@ def apply(self, generator, data={}): child_macros.update({key : to_assign}) + if self.name: + self.subnode.name = self.name + return self.subnode.apply(generator, data=child_macros) @@ -598,7 +601,7 @@ def apply(self, generator, data={}): class StretchNode(Node): def __init__(self, name=None, layout={}, flow="vertical", subnode=None, loc=None): super(StretchNode, self).__init__("Stretch", name=name, layout=layout, loc=loc) - + self.setProperty("flow", flow, internal=True) self.subnode = subnode @@ -614,6 +617,10 @@ def apply (self, generator, data={}): if flow == "horizontal" or flow=="all": applied_node["geometry"]["width"] = data["__parentwidth__"] + if self.name: + print(self.location) + applied_node.name = self.name + applied_node = applied_node.apply(generator, data=data) applied_node["geometry"]["x"] = applied_node["geometry"]["x"] + self["geometry"]["x"] @@ -632,6 +639,9 @@ def __init__(self, name=None, layout={}, flow="vertical", subnode=None, loc=None self.tocopy.append("subnode") def apply (self, generator, data={}): + if self.name: + self.subnode.name = self.name + applied_node = self.subnode.apply(generator, data=data) flow = self.getProperty("flow", internal=True).val() @@ -656,6 +666,9 @@ def __init__(self, name=None, layout={}, flow="vertical", subnode=None, loc=None def apply (self, generator, data={}): + if self.name: + self.subnode.name = self.name + applied_node = self.subnode.apply(generator, data=data) flow = self.getProperty("flow", internal=True).val() diff --git a/gestalt/convert/phoebus/CSSGenerator.py b/gestalt/convert/phoebus/CSSGenerator.py index 7ae2fce..c5242b9 100644 --- a/gestalt/convert/phoebus/CSSGenerator.py +++ b/gestalt/convert/phoebus/CSSGenerator.py @@ -246,6 +246,8 @@ def generateCSSFile(template, data, outputfile=""): for key, item in template.items(): if isinstance(item, Node): + item.name = key + if item.classname == "Form": for key, val in item.properties["attrs"].items(): a_display.setProperty(key, val) diff --git a/gestalt/convert/phoebus/CSSWidget.py b/gestalt/convert/phoebus/CSSWidget.py index 1110179..98d65db 100644 --- a/gestalt/convert/phoebus/CSSWidget.py +++ b/gestalt/convert/phoebus/CSSWidget.py @@ -34,6 +34,14 @@ def __init__(self, classname, node=None, name=None, layout={}, macros={}): self.name = classname + str(num) + else: + num = name_numbering.get(self.name, 0) + num += 1 + name_numbering[self.name] = num + + if (num > 1): + self.name = self.name + str(num) + if (self.classname == "ActionButton"): self.widget = widget.ActionButton(self.name, "", "", 0, 0, 0, 0) elif (self.classname == "Arc"): diff --git a/gestalt/convert/qt/QtGenerator.py b/gestalt/convert/qt/QtGenerator.py index 8b70d2b..23ece2c 100644 --- a/gestalt/convert/qt/QtGenerator.py +++ b/gestalt/convert/qt/QtGenerator.py @@ -105,7 +105,7 @@ def generateMenu(self, node, macros={}): output.link("channel", "pv") - output["colorMode"] = Enum("caMenu::Static") + output["colorMode"] = Enum("caMenu::Static") return output @@ -226,7 +226,7 @@ def generatePolyline(self, node, macros={}): my_points = List(node.points) my_points.apply(macros) - + for point in my_points: a_point = Rect(point) a_point.apply(macros) @@ -285,6 +285,8 @@ def generateQtFile(template, data, outputfile=""): for key, item in template.items(): if isinstance(item, Node): + item.name = key + if item.classname == "Form": for key, val in item.properties["attrs"].items(): a_display.setProperty(key, val) diff --git a/gestalt/convert/qt/QtWidget.py b/gestalt/convert/qt/QtWidget.py index 60c110a..46ccfa6 100644 --- a/gestalt/convert/qt/QtWidget.py +++ b/gestalt/convert/qt/QtWidget.py @@ -45,7 +45,14 @@ def __init__(self, classname, node=None, name=None, layout={}, macros={}, loc=No name_numbering[classname] = num self.name = classname + str(num) - + + else: + num = name_numbering.get(self.name, 0) + num += 1 + name_numbering[self.name] = num + + if (num > 1): + self.name = self.name + str(num) def write(self, tree): # Border-width is default in GroupNode