From 431b9f63048850f6e3151b1bfd8650143f50dfe7 Mon Sep 17 00:00:00 2001 From: tassaron Date: Mon, 22 May 2017 22:25:38 -0400 Subject: colors are configurable in the GUI any invalid RGB tuple entered will result in white --- core.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'core.py') diff --git a/core.py b/core.py index b693837..6981b87 100644 --- a/core.py +++ b/core.py @@ -194,3 +194,17 @@ class Core(): shell=True ) return sorted([os.path.join(self.tempDir, f) for f in os.listdir(self.tempDir)]) + + @staticmethod + def RGBFromString(string): + ''' turns an RGB string like "255, 255, 255" into a tuple ''' + try: + tup = tuple([int(i) for i in string.split(',')]) + if len(tup) != 3: + raise ValueError + for i in tup: + if i > 255 or i < 0: + raise ValueError + return tup + except: + return (255, 255, 255) -- cgit v1.2.3