]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/commitdiff
Unset description / color when they are removed
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Thu, 11 Aug 2016 10:59:29 +0000 (12:59 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Thu, 11 Aug 2016 10:59:29 +0000 (12:59 +0200)
music_sampler/key.py

index b05de4cbeef381a33602b848870ea3fb50540120..bdae5bdacf495d29576af27555923808e0fff72b 100644 (file)
@@ -189,8 +189,12 @@ class Key(ButtonBehavior, Widget):
 
             if 'description' in self.config['properties']:
                 self.set_description(self.config['properties']['description'])
+            else:
+                self.unset_description()
             if 'color' in self.config['properties']:
                 self.set_color(self.config['properties']['color'])
+            else:
+                self.unset_color()
             self.success()
         else:
             self.no_config()
@@ -250,10 +254,17 @@ class Key(ButtonBehavior, Widget):
             else:
                 self.description.append(str(desc).replace(" ", " "))
 
+    def unset_description(self):
+        self.description_title = ""
+        self.description = []
+
     def set_color(self, color):
         color = [x / 255 for x in color]
         self.custom_color = color
 
+    def unset_color(self):
+        self.custom_color = [0, 1, 0]
+
     # Actions handling
     def add_action(self, action_name, **arguments):
         self.actions.append(Action(action_name, self, **arguments))