Skip to content

Commit

Permalink
Pass along naming conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
keenanlang committed Jul 29, 2024
1 parent 16a75ae commit 6b41bad
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 4 deletions.
15 changes: 14 additions & 1 deletion gestalt/Node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand All @@ -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
Expand All @@ -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"]
Expand All @@ -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()
Expand All @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions gestalt/convert/phoebus/CSSGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions gestalt/convert/phoebus/CSSWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down
6 changes: 4 additions & 2 deletions gestalt/convert/qt/QtGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 8 additions & 1 deletion gestalt/convert/qt/QtWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6b41bad

Please sign in to comment.