<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">On 20 Dec 2009, at 04:04, Greg Ewing wrote:<br><br><blockquote type="cite">Dan Villiom Podlaski Christiansen wrote:<br><br><blockquote type="cite">I'm seeing a weird issue; for some &nbsp;reason ‘Open as…’ and ‘Save as…’<br></blockquote>&gt; create a menu item per character in their name.<br><br>Sounds like it thinks they're menu item groups instead of<br>single items.<br><br>Are these perhaps unicode strings? In Generic/GMenus.py,<br>Menu._make_item(), there's the following piece of code:<br><br>&nbsp;if isinstance(text, str):<br>&nbsp;&nbsp; return SingleMenuItem(text, cmd, substitutions)<br>&nbsp;else:<br>&nbsp;&nbsp; return MenuItemGroup(text, cmd)<br><br>This could get confused if it's given a unicode string<br>instead of a plain str. It should probably be amended to<br>take unicode into account.<br></blockquote><div><br></div>Indeed; changing the check to basestring fixed it :) (It was caused by me making ‘Save as…’, etc., use Unicode strings for the ellipsis.)<div><br></div><div>I have another issue where you may have an idea what I'm doing wrong…</div><div><br></div><div><blockquote type="cite"><font class="Apple-style-span" color="#000000">Traceback (most recent call last):<br>&nbsp;&nbsp;File "/opt/python/lib/python/GUI/Generic/GApplications.py", line 379, in report_error<br>&nbsp;&nbsp; &nbsp;raise<br>TypeError: exceptions must be classes or instances, not NoneType</font><br></blockquote><div><br></div><div>The relevant snippet of code in -[PyApplication sendEvent:] looks like this:</div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal 'Anonymous Pro'; ">r =&nbsp;<span style="color: rgb(0, 52, 252); ">PyObject_CallMethod</span>(<span style="color: rgb(160, 51, 240); "><b>self</b></span>.<span style="color: rgb(184, 134, 23); ">app</span>,&nbsp;<span style="color: rgb(188, 143, 143); ">"handle"</span>,&nbsp;<span style="color: rgb(188, 143, 143); ">"OO"</span>, kind, pyevent);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal 'Anonymous Pro'; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal 'Anonymous Pro'; "><span style="color: rgb(160, 51, 240); "><b>if</b></span>&nbsp;(r ==&nbsp;<span style="color: rgb(160, 51, 240); "><b>NULL</b></span>) {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal 'Anonymous Pro'; ">&nbsp;&nbsp; &nbsp;<span style="color: rgb(0, 52, 252); ">PyObject_CallMethod</span>(<span style="color: rgb(160, 51, 240); "><b>self</b></span>.<span style="color: rgb(184, 134, 23); ">app</span>,&nbsp;<span style="color: rgb(188, 143, 143); ">"report_error"</span>,&nbsp;<span style="color: rgb(188, 143, 143); ">""</span>);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal 'Anonymous Pro'; ">}</div><div><font class="Apple-style-span" face="'Anonymous Pro'" size="3"><span class="Apple-style-span" style="font-size: 12px;"><br></span></font></div></div><div>I'm not terribly familiar with how exceptions work with the Python API, but shouldn't that suffice? (The ‘app’ property accessor imports the Applications module and calls the ‘application()’ accessor in it to obtain the PyGUI application instance.)</div><div><br></div><div>(I sent this email as rich text because of the code paste; I hope you don't mind!)</div><br><div>--<br><br>Dan Villiom Podlaski Christiansen<br><a href="mailto:danchr@gmail.com">danchr@gmail.com</a><br></div><div><br></div><img height="233" width="537" apple-width="yes" apple-height="yes" id="6c3ca7a2-a31c-4fb5-89b1-7eb0cc157070" src="cid:7F12606C-0CB3-432C-9DE4-A8BC7105EC49"></div></body></html>