the other trick, if you plan in being able to run other scripts, is you need to bypass global clearing for your code.

there are a few ways to do this. the best way is to have all of your code in a module that is in site-packages, import the module, then call some main() to show the ui. modules in site-packages don't get cleared when running other code. Other approaches are to ensure everything you need is in a single custom view class, with no use of globals (callbacks should use self, or sender). all methods should explictly import anything that is needed, since imports might dissappear from globals. when you present the custom view, the object won't be cleared until it is explictly closed.