]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/samples/wxPIA_book/Chapter-06/example7.py
Don't try to access a color not in the dictionary
[wxWidgets.git] / wxPython / samples / wxPIA_book / Chapter-06 / example7.py
index 626827fbe014b1e0f4ef5e7c3034964a784f32cc..74f91ac4d8d598458e7c00fa138948a764c1b959 100644 (file)
@@ -188,7 +188,7 @@ class SketchFrame(wx.Frame):
         dlg.Destroy()
 
     def OnOtherColor(self, event):
-        dlg = wx.ColourDialog(frame)
+        dlg = wx.ColourDialog(self)
         dlg.GetColourData().SetChooseFull(True)
         if dlg.ShowModal() == wx.ID_OK:
             self.sketch.SetColor(dlg.GetColourData().GetColour())
@@ -302,7 +302,7 @@ class ControlPanel(wx.Panel):
 
     def OnSetColour(self, event):
         color = self.colorMap[event.GetId()]
-        if color != self.sketch.color:
+        if color != self.sketch.color and self.sketch.color in self.colorButtons:
             self.colorButtons[self.sketch.color].SetToggle(False)
         self.sketch.SetColor(color)