Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
230 views
in Technique[技术] by (71.8m points)

python - My tkinter entry box is printing .!entry instead of what is entered

from tkinter import *
def _name_():
              businessname=entry_bn
              print(businessname)
edit_bar=Tk()
name=Label(edit_bar,text="Name:").grid(row=0)
entry_bn=Entry(edit_bar)
entry_bn.grid(row=0,column=1)
submit=Button(edit_bar,text="Submit",command=_name_).grid(row=1,column=2)

Whenever i press my submit button, i get .!entry printed out, instead of what is entered into the entry box. Any ideas? Thank you

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Question: i get .!entry printed out, instead of what is entered into the Entry


Reference:


import tkinter as tk


class App(tk.Tk):
    def __init__(self):
        super().__init__()

        tk.Label(self, text="Name:").grid(row=0, column=0)
        self.entry = tk.Entry(self)
        self.entry.grid(row=0, column=1)

        btn = tk.Button(self, text="Submit", command=self.on_submit)
        btn.grid(row=2, column=0, columnspan=2, sticky='ew')

    def on_submit(self):
        print('Name: {}'.format(self.entry.get()))


if __name__ == "__main__":
    App().mainloop()

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...