From 353e51d6dd494971a1dda2ef1674b383881f6a8f Mon Sep 17 00:00:00 2001 From: Keegi Date: Wed, 3 Aug 2011 22:27:41 +0300 Subject: [PATCH] fix specifying colours causing exception --- pronterface.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pronterface.py b/pronterface.py index ae08ad1..419c070 100755 --- a/pronterface.py +++ b/pronterface.py @@ -638,7 +638,10 @@ class PronterWindow(wx.Frame,pronsole.pronsole): self.save_in_rc(("button %d" % n),'') elif len(bdef)>2: colour=bdef[2] - if not isinstance(colour,str): + if type(colour) not in (str,unicode): + print type(colour) + if type(colour)==tuple and map(type,colour)==(int,int,int): + colour = map(lambda x:x%256,colour) colour = wx.Colour(colour).GetAsString(wx.C2S_NAME|wx.C2S_HTML_SYNTAX) self.save_in_rc(("button %d" % n),'button %d "%s" /c "%s" %s' % (new_n,bdef[0],colour,bdef[1])) else: @@ -652,7 +655,10 @@ class PronterWindow(wx.Frame,pronsole.pronsole): bedit.command.SetValue(button.properties[1]) if len(button.properties)>2: colour=button.properties[2] - if not isinstance(colour,str): + if type(colour) not in (str,unicode): + print type(colour) + if type(colour)==tuple and map(type,colour)==(int,int,int): + colour = map(lambda x:x%256,colour) colour = wx.Colour(colour).GetAsString(wx.C2S_NAME|wx.C2S_HTML_SYNTAX) bedit.color.SetValue(colour) else: