Cannot start Tkinter window in Visual Studio with Python Tools

python, tkinter, visual-studio, visual-studio-2013

Solution

Most likely the problem is that you aren't starting the event loop. Without the event loop the program will exit immediately. Try altering your program to look like this:

import tkinter as tk
root = tk.Tk()
root.mainloop()

The reason you don't need to call mainloop in IDLE is because IDLE does that for you. In all other cases you must call mainloop.

Problem

I am developing using Python Tools for Visual Studio in Visual Studio 2013 community edition on Windows 8.1. My problem is that I am unable to get a Tkinter window to start. I have tried using this code: ``` from tkinter import * Tk() ``` When I launch this code from IDLE and such, I am able to get a tkinter window, as shown: However, when I start this in Visual Studio, no Tkinter window appears, only the console window. No error is thrown. Example: How do I get the Tkinter window to appear when I launch the program in Visual Studio with Python tools? Edit: Also, when I try to do this from the Python interactive window in VS, this is what I get, with no window appearing: ``` >>> from tkinter import * >>> Tk() <tkinter.Tk object at 0x02D81FD0> ```

Original source