I want to be able to bring up an interactive python terminal from my python application. Some, but not all, variables in my program needs to be exposed to the interpreter.>
It sounds like you did something similar to my Veusz application, https://veusz.github.io/. I thought you might find it useful to see a more complete implementation. I can't post hyperlinks but have a look at windows/consolewindow.py for the widget class. Commands are executed by the document/commandinterpreter.py class. The interface is defined in document/commandinterface.py. It's mostly done manipulating a dict however.