dabo Commit
Revision 4981
Date: 2009-01-26 12:07:27 -0800 (Mon, 26 Jan 2009)
Author: Paul
Trac: http://trac.dabodev.com/changeset/4981

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

Log:
Was getting the following traceback (snipped to relevant):

  File "/home/pmcnett/dabo/dabo/lib/datanav/Form.py", line 255, in setupMenu
    menuIndex = mb.getMenuIndex(_("Actions"))
  File "/home/pmcnett/dabo/dabo/ui/uiwx/dMenuBar.py", line 156, in getMenuIndex
    mn = self.getMenu(idOrCaption)
  File "/home/pmcnett/dabo/dabo/ui/uiwx/dMenuBar.py", line 146, in getMenu
    ret = self.GetMenu(idx)
  File "/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/_core.py", line 
11260, in GetMenu
    return _core_.MenuBar_GetMenu(*args, **kwargs)
ValueError: in method 'MenuBar_GetMenu', expected argument 2 of type 'size_t'

Fixed by checking that idx >= 0.



Diff:
Modified: trunk/dabo/ui/uiwx/dMenuBar.py
===================================================================
--- trunk/dabo/ui/uiwx/dMenuBar.py      2009-01-26 14:28:30 UTC (rev 4980)
+++ trunk/dabo/ui/uiwx/dMenuBar.py      2009-01-26 20:07:27 UTC (rev 4981)
@@ -134,20 +134,24 @@
                The MenuID property is checked first; then the Caption. If no 
match is found, 
                None is returned.
                """
+               id = caption = idOrCaption
                try:
-                       ret = [mn for mn in self.Children
-                                       if mn.MenuID == idOrCaption][0]
+                       return [mn for mn in self.Children if mn.MenuID == 
id][0]
                except IndexError:
-                       ret = None
-                       # Try the Caption
-                       idx = self.FindMenu(idOrCaption)
-                       try:
-                               ret = self.GetMenu(idx)
-                       except dabo.ui.assertionException:
-                               ret = None
-               return ret
+                       pass
 
+               # Finding the id failed; try the Caption
+               idx = self.FindMenu(caption)
+               if idx is None or idx < 0:
+                       return None
 
+               # The menu index was found by caption: return the menu:
+               try:
+                       return self.GetMenu(idx)
+               except dabo.ui.assertionException:
+                       return None
+
+
        def getMenuIndex(self, idOrCaption):
                """Returns the index of the menu with the specified ID or 
caption.
                If the menu isn't found, None is returned.



_______________________________________________
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