dabo Commit
Revision 6165
Date: 2010-10-25 06:36:30 -0700 (Mon, 25 Oct 2010)
Author: Ed
Trac: http://trac.dabodev.com/changeset/6165

Changed:
U   trunk/dabo/ui/uiwx/dKeys.py

Log:
Fixed the case where binding a single '+' key would cause an exception.


Diff:
Modified: trunk/dabo/ui/uiwx/dKeys.py
===================================================================
--- trunk/dabo/ui/uiwx/dKeys.py 2010-10-25 12:41:44 UTC (rev 6164)
+++ trunk/dabo/ui/uiwx/dKeys.py 2010-10-25 13:36:30 UTC (rev 6165)
@@ -1,6 +1,7 @@
 # -*- coding: utf-8 -*-
 import wx
 import dabo
+from dabo.dLocalize import _
 
 key_Alt = wx.WXK_ALT
 try:
@@ -253,15 +254,23 @@
        same as above, but with a thrid element that is a numeric value 
compatible with
        what wxPython expects.
        """
-       if keyCombo.endswith("+"):
-               # Strip off the trailing two characters
-               keys = keyCombo[:-2].split("+")
-               keys.append("+")
+       if not isinstance(keyCombo, basestring) or not keyCombo.strip():
+               raise ValueError(_("Invalid key combination: '%s'") % keyCombo)
+       parts = keyCombo.split("+")
+       if len(parts) == 1:
+               # A single character
+               key = parts[0]
+               parts = []
        else:
-               keys = keyCombo.split("+")
+               # Special case: handle the '+' key, which will create two empty 
elements at the end
+               if parts[-2:] == ["", ""]:
+                       key = "+"
+                       parts = parts[:-2]
+               else:
+                       key = parts[-1]
+                       parts = parts[:-1]
        # The modifier keys, if any, comprise all but the last key in keys
-       mods = [k.lower() for k in keys[:-1]]
-       key = keys[-1]
+       mods = [p.lower() for p in parts]
        if returnFlags:
                # Convert the string mods and key into the correct parms for wx:
                flags = mod_Normal



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to