Search code examples
pythonmemory-addressmayaviipython-magic

Memory address of ipython magic functions


I have been experimenting with the scriptable visualization tool mayavi from ipython's terminal. Mayavi uses the wx backend, and therefore I call the magic function just to check the address, then change the gui and check again the address to make sure the change has taken effect (although I know it's a bit useless):

In [1]: %gui
Out[1]: <CFunctionType object at 0x03491D50>

In [2]: %gui wx
Out[2]: <wx._core.App; proxy of <Swig Object of type 'wxPyApp *' at 0x33a8ea8> >

In [3]: %gui
Out[3]: <CFunctionType object at 0x0354AEB8>

In [4]: %gui
Out[4]: <CFunctionType object at 0x0354AF30>

The question why are the addresses in 3 and 4 different ?


Solution

  • From the docs:

    For users, enabling GUI event loop integration is simple. You simple use the %gui magic as follows:

    %gui [GUINAME]

    With no arguments, %gui removes all GUI support.

    Valid GUINAME arguments are wx, qt, gtk and tk.

    Thus, to use wxPython interactively and create a running wx.App object, do: %gui wx