Using Tkinter/Turtle or Pyglet in Canopy's IPython panel

By default, commands executed in Canopy's IPython shell run in IPython's interactive Pylab mode, using Qt as the graphical backend. 

Tkinter is also an interactive graphical backend, and a program cannot have two interactive backends at once. So to run Tkinter from the IPython shell, you can disable pylab, or you can change the pylab backend to inline (SVG), which is not interactive. These settings are controlled from the Canopy Preferences menu, on the Python tab.

You do not need to restart Canopy after changing Pylab/backend settings. Just restart the Kernel (in the Run menu).

If you do disable pylab, you can still get its automatic global imports by typing, on startup, ipython's magic command:

Or, if you are switching from a TKinter-based activity, with pylab disabled, to a Qt-based activity, you can type this magic to get the same behavior as in Canopy's default:
%pylab qt

(Note that in Python version 3, the capitalization of the imported module was changed from `Tkinter` to the more standard form `tkinter` "Checking your Tkinter support" on the Python TKinter wiki page.)


Pyglet: the same GUI backend considerations apply to Pyglet as to TKinter.


Have more questions? Submit a request


Powered by Zendesk