user2525477
user2525477

Reputation: 17

Using tkinter module nothing is happening

I am relatively new to python, and i have this program that runs without errors without doing anything.

from tkinter import *
tk = Tk()
btn = Button(tk, text="click me")
btn.pack()

it runs without errors and then in the idle shell it just shows the next prompt (>>>) without doing anything. Oh, by the way i am using python 3.2

Upvotes: 0

Views: 597

Answers (1)

schlenk
schlenk

Reputation: 7237

Most GUI frameworks need you to enter the gui mainloop to have anything happening.

Try adding a mainloop call at the end:

from tkinter import *
tk = Tk() 
btn = Button(tk, text="click me")
btn.pack()
tk.mainloop()

Maybe have a look at the tutorial at http://www.tkdocs.com

Upvotes: 2

Related Questions