From 7ff2d30a1c16216f3bfaebc8f71924d6a6f8ec8d Mon Sep 17 00:00:00 2001 From: Blaine Date: Sat, 20 Jun 2020 12:35:09 +0530 Subject: complete string formatting --- src/main/python/utils/custom.py | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'src/main') diff --git a/src/main/python/utils/custom.py b/src/main/python/utils/custom.py index 5625ea4..7e6b197 100644 --- a/src/main/python/utils/custom.py +++ b/src/main/python/utils/custom.py @@ -125,13 +125,31 @@ class ShapeDialog(QDialog): entry.append(i.width) gripList.append(entry) + + grips = ",\n ".join([str(i) for i in gripList]) if gripList else "" + if grips: + grips = "self.grips = [" + grips + "]\n" temp = QDialog(self) tempLayout = QBoxLayout(QBoxLayout.TopToBottom) - output = OutputBox(temp, f"""class {className}(NodeItem): - def __init__(self): - super({className}, self).__init__("svg/{category}/{str.split(name[0], "/")[-1][:-4]}") - self.grips = {gripList} - """) + output = OutputBox(temp, f""" + Class Definition: +
+class {className}(NodeItem):
+    def __init__(self):
+        super({className}, self).__init__("svg/{category}/{str.split(name[0], "/")[-1][:-4]}")
+    {grips}
+
+ Items.json entry: +
+"{category}": {{
+    "{itemName}": {{
+        "name": "{itemName}",
+        "icon": ".\\{category}\\{str.split(name[0], "/")[-1]}",
+        "class": "{category}",
+        "object": "{className}",
+        "args": []
+    }}
+}}
""") tempLayout.addWidget(output) temp.setLayout(tempLayout) temp.exec() @@ -229,6 +247,5 @@ class OutputBox(QTextEdit): def __init__(self, parent, text): super(OutputBox, self).__init__(parent) self.setReadOnly(True) - self.resize(600, 300) - self.text = text - self.setMarkdown("```python\n"+text+"\n```") + self.setFontWeight(10) + self.setHtml(text) \ No newline at end of file -- cgit