Does Spyder 2 support interactive use of Tkinter?

3,140 views
Skip to first unread message

Chris Ball

unread,
Dec 15, 2010, 4:56:17 PM12/15/10
to spyder
Hi,

First, thanks for Spyder and all your hard work on it! I think it's
really great.

We would love people to be able to use our simulator software with
Spyder. Unfortunately, it does not seem to be possible to use Spyder
effectively when running our simulator's GUI, which is written in
Tkinter. The GUI works fine with IEP (http://code.google.com/p/iep/),
which appears to include special code to support the event loops of
various GUI toolkits.

In an ordinary Python 2 interpreter, one can use Tkinter interactively
(I have never used Python 3). For instance, the following code causes
a Tkinter window to appear:
import Tkinter
t = Tkinter.Tk()

In a Spyder 2 shell (both IPython and regular), the code above causes
a window to be created, but it is not displayed properly (apparently
Tkinter events are not being processed). Calling t.mainloop() causes
the window to display correctly, but then the console can no longer
accept input (until the Tk mainloop is finished, usually by destroying
the window). I believe that the ordinary Python 2 interpreter includes
special support for having Tkinter process events without calling its
mainloop, and apparently IEP also includes special support (I haven't
investigated this support in either case).

I searched this mailing list and the issue tracker for issues relating
to Tkinter, but I didn't see anything relevant. I hope I didn't miss
something! If you agree this is a missing feature from Spyder, I could
file an issue and then try to help out with it (although I don't
currently know anything more than I have described here,
unfortunately...).

Thanks,

Chris
(http://topographica.org/)

Carlos Córdoba

unread,
Dec 16, 2010, 5:35:54 PM12/16/10
to spyd...@googlegroups.com
Hi Chris,

After a couple of hours searching for a solution to your problem, I
found that IPython solves it in a really simple way.

Please go to "Tools/Preferences", then select the "Console" section and
then go to the "External Modules" tab. In the IPYTHON section change the
options that appear there to these ones:

-pylab -tk -colors LightBG -xmode Plain

Preserve the exact order that I'm giving to you, else it won't work.
These options are passed to the Ipython interpreter. In particular -tk
(after -pylab) takes care of the interactive use of Tkinter. If you want
to know more, please read the Ipython help running in a shell:

ipython --help

If you have more problems, please report them on this thread.

Carlos

El 15/12/10 16:56, Chris Ball escribió:

Carlos Córdoba

unread,
Dec 16, 2010, 5:54:17 PM12/16/10
to spyd...@googlegroups.com
PS. I'm really glad to hear that you're interested in spyder and want to
use it for your project. Please tell us how all that goes! :-)

El 16/12/10 17:35, Carlos Córdoba escribió:

Chris Ball

unread,
Dec 17, 2010, 10:10:19 AM12/17/10
to spyder
On Dec 16, 10:35 pm, Carlos Córdoba <ccordob...@gmail.com> wrote:
> Hi Chris,
>
> After a couple of hours searching for a solution to your problem, I
> found that IPython solves it in a really simple way.
>
> Please go to "Tools/Preferences", then select the "Console" section and
> then go to the "External Modules" tab. In the IPYTHON section change the
> options that appear there to these ones:
>
> -pylab -tk -colors LightBG -xmode Plain
>
> Preserve the exact order that I'm giving to you, else it won't work.

Thanks - that does indeed work!

> These options are passed to the Ipython interpreter. In particular -tk
> (after -pylab) takes care of the interactive use of Tkinter. If you want
> to know more, please read the Ipython help running in a shell:
>
> ipython --help

I was unaware of this option, having never had to use it (when I
launch IPython manually, Tkinter support just works).


We're excited that our users will now be able to use Spyder! We still
have to do more testing, but we'll report back here on the results.

Thanks again,
Chris

Carlos Córdoba

unread,
Dec 19, 2010, 10:04:38 AM12/19/10
to spyd...@googlegroups.com
El 17/12/10 10:10, Chris Ball escribió:

> On Dec 16, 10:35 pm, Carlos Córdoba<ccordob...@gmail.com> wrote:
>> Hi Chris,
>>
>> After a couple of hours searching for a solution to your problem, I
>> found that IPython solves it in a really simple way.
>>
>> Please go to "Tools/Preferences", then select the "Console" section and
>> then go to the "External Modules" tab. In the IPYTHON section change the
>> options that appear there to these ones:
>>
>> -pylab -tk -colors LightBG -xmode Plain
>>
>> Preserve the exact order that I'm giving to you, else it won't work.
> Thanks - that does indeed work!

I'm glad to hear it :-)

>> These options are passed to the Ipython interpreter. In particular -tk
>> (after -pylab) takes care of the interactive use of Tkinter. If you want
>> to know more, please read the Ipython help running in a shell:
>>
>> ipython --help
> I was unaware of this option, having never had to use it (when I
> launch IPython manually, Tkinter support just works).

That's the case when you launch ipython with no additional option, but
if you launch it with ipython -pylab (so you can use matplotlib
interactively) then you loose Tkinter interactive support. And for the
record, I had never had to read Ipython's help until your problem!

Robert Anue

unread,
Aug 6, 2016, 1:40:44 PM8/6/16
to spyder
Hi Carlos, 

I am using the latest anaconda release, and I have the same problem.  I can launch a tkinter window, and everything works just fine, EXCEPT while the window is open I can not type anything into the ipython console.  It would be so helpful to have access to the console for debugging and development.  

I can't find comparable preferences to the ones you talk about, nor do I know anaconda well enough to find the command line that they launch ipython from.  
Any help, or should I switch out of anaconda?

-Rob

John Lambert

unread,
Aug 8, 2016, 10:49:36 AM8/8/16
to spyder
What are the options to enable this on Spyder 3?  The iptython options don't appear in the "External Modules" section.  I have run into this as well in using Spyder and, if possible, it would be nice if it "just worked" out of the box, and/or integrated backend option selection in the preferences.

Thanks,
John

Misha Smirnov

unread,
Apr 18, 2017, 8:01:49 PM4/18/17
to spyder
For those using the newer versions of spyder (i'm using spyder3 with anaconda), I've found that you need to go to Tools -> Preferences -> IPython -> Graphics, and select Tkinter from the graphics backend dropdown to get this effect.
Reply all
Reply to author
Forward
0 new messages