Browse Source

Add the todo.png image as default if the icon is not found

Yentl Van Tendeloo 6 years ago
parent
commit
62bb816d58
4 changed files with 13 additions and 7 deletions
  1. 4 2
      classes/toolbar/generic_toolbar.xml
  2. 5 3
      frontend.py
  3. 0 1
      icons/upload_ALC.png
  4. 4 1
      sccd_widget.py

+ 4 - 2
classes/toolbar/generic_toolbar.xml

@@ -11,9 +11,11 @@
             <parameter expr="parent"/>
         </super>
         <body>
-            self.to_create = ["new", "open"]
+            self.to_create = ["new", "open", "activity"]
             self.button_info = {"new": "Create a new model",
-                                "open": "Open an existing model"}
+                                "open": "Open an existing model",
+                                "activity": "Perform an activity",
+                               }
             self.buttons = {}
             tk.Label(self, text="Generic").pack(side=tk.LEFT)
         </body>

+ 5 - 3
frontend.py

@@ -1,7 +1,7 @@
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Mon Oct 16 13:13:42 2017
+Date:   Mon Oct 16 13:43:48 2017
 
 Model author: Yentl Van Tendeloo
 Model name:   Modelverse Visual Editor - Tkinter Version 
@@ -7233,9 +7233,11 @@ class GenericToolbar(Toolbar):
     
     def user_defined_constructor(self, parent):
         Toolbar.user_defined_constructor(self, parent)
-        self.to_create = ["new", "open"]
+        self.to_create = ["new", "open", "activity"]
         self.button_info = {"new": "Create a new model",
-                            "open": "Open an existing model"}
+                            "open": "Open an existing model",
+                            "activity": "Perform an activity",
+                           }
         self.buttons = {}
         tk.Label(self, text="Generic").pack(side=tk.LEFT)
     

+ 0 - 1
icons/upload_ALC.png

@@ -1 +0,0 @@
-todo.png

+ 4 - 1
sccd_widget.py

@@ -253,7 +253,10 @@ class TextVisual(Visual):
 class ImageVisual(Visual):
     def __init__(self, img_loc):
         super(ImageVisual, self).__init__()
-        self.img = ImageTk.PhotoImage(Image.open(img_loc).resize((32, 32), Image.ANTIALIAS))
+        try:
+            self.img = ImageTk.PhotoImage(Image.open(img_loc).resize((32, 32), Image.ANTIALIAS))
+        except:
+            self.img = ImageTk.PhotoImage(Image.open("icons/todo.png").resize((32, 32), Image.ANTIALIAS))
 
     def get_params(self):
         return {'image': self.img}