<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Richard,<div><span class="Apple-tab-span" style="white-space:pre"> </span>The issue here is that Chimera executes Python scripts in temporary modules so that they don't interact with Chimera's own global namespace (they don't accidentally pick up names from the global namespace nor do they leave definitions there). After the script is executed, the temporary module is deleted from sys.modules. When that happens Python clears references in the module's globals dictionary by setting the values to None in an attempt to break circular references for garbage-collection and destructor-invocation purposes. So... the script's attempt to use those names later (when the toolbar button is pressed) produces the "<font class="Apple-style-span" color="#000000"><span class="Apple-style-span" style="background-color: transparent;">'NoneType' object has no attribute 'compile'" error since when Python looks up "re" in the module's globals dictionary it gets 'None' back.</span></font></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>The fix is to put "import re" inside the function definition (as well as an additional "import chimera" [an import is still required at the global level for code after the button-callback function]). I will need to update the example to account for this behavior. The example was written back when scripts were executed in Chimera's own namespace.</div><div><br></div><div>--Eric</div><div><br><div><div>On Apr 1, 2009, at 11:36 AM, Chimera wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>#7111: problem with "toolbar buttons" programmer's example<br>-----------------------------------------------+----------------------------<br> Reporter: richard.marhoefer@… | Owner: pett <br> Type: defect | Status: accepted <br> Priority: normal | Milestone: Release 1.4 <br>Component: Core | Version: 1.0 (build 2540)<br> Severity: normal | Keywords: <br>Blockedby: | Project: chimera <br> Platform: all | Blocking: <br>-----------------------------------------------+----------------------------<br>Changes (by pett):<br><br> * status: new => accepted<br> * reporter: chimera-bug-report@… => richard.marhoefer@…<br> * component: => Core<br> * project: => chimera<br> * platform: => all<br> * version: => 1.0 (build 2540)<br> * milestone: => Release 1.4<br> * owner: => pett<br><br><br>-- <br>Ticket URL: <<a href="http://socrates2.cgl.ucsf.edu/trac/chimera/ticket/7111#comment:2">http://socrates2.cgl.ucsf.edu/trac/chimera/ticket/7111#comment:2</a>><br>Chimera <<a href="http://socrates2.cgl.ucsf.edu/trac/chimera">http://socrates2.cgl.ucsf.edu/trac/chimera</a>><br>Chimera Issue Tracker<br></div></blockquote></div><br></div></body></html>