これでちゃんとボタンも入力欄も機能するよ。
#!/usr/bin/env python import sys import tkinter as tk _t = "はじめてのpython/tk" root = tk.Tk() root.title(_t) def get_id_pass(): _id = text1.get() _pass = text2.get() print("ID:"+_id) print("PASS:"+_pass) sys.stdout.flush() def set_clear(): text1.set('') text2.set('') # オブジェクト label1 = tk.Label(root,text="Username") label2 = tk.Label(root,text="Password") text1 = tk.StringVar() text2 = tk.StringVar() entry1 = tk.Entry(root,textvariable=text1) entry2 = tk.Entry(root,textvariable=text2) btn1 = tk.Button(root,text = 'ENTER',command=lambda:get_id_pass()) btn2 = tk.Button(root,text = 'CLEAR',command=lambda:set_clear()) btn3 = tk.Button(root,text = 'Quit',command=quit) label1.grid(row=0,column=0) entry1.grid(row=0,column=1) label2.grid(row=1,column=0) entry2.grid(row=1,column=1) btn1.grid(row=2,column=0) btn2.grid(row=2,column=1) btn3.grid(row=2,column=2) # Window root.mainloop()