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

2024/11/18 21:27:08
from tkinter import *
def _name_():businessname=entry_bnprint(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

Answer

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


Reference:

  • Tkinter.Entry.get-method

    Gets the current contents of the entry field. Returns the widget contents, as a string.


import tkinter as tkclass 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()
https://en.xdnf.cn/q/118623.html

Related Q&A

How to get an average from a row then make a list out of it [duplicate]

This question already has answers here:Reading a CSV file, calculating averages and printing said averages(2 answers)Closed 6 years ago.If I have a csv data that gives two row values of:years grades 20…

Beautiful soup: Extract everything between two tags when these tags have different ids

Beautiful soup: Extract everything between two tags I have seen a question through the above link where we are getting the information between two tags. Whereas I need to get the information between th…

exceptions.RuntimeError - Object has no attribute errno [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.Want to improve this question? Add details and clarify the problem by editing this post.Closed 6 years ago.Improve…

How can I translate this python function to c++?

I am trying to translate a python function to c++ without success. Can someone help me? The python function receives as input a string S and 2 integers (fragment_size and jump). The aim of this functi…

Reverse PDF imposition

I have an imposed document: there are 4 n A4 pages on the n sheets. I put them into a roller image scanner and receive one 2 n paged PDF document (A3).If, say, n = 3, then Ive got the following seque…

Python: How to run flask mysqldb on Windows machine?

Ive installed the flask-mysqldb module with pip package management system on my Windows machine and I dont know how to run it.I have tried to add the path to the MySQLdb in System properties and still …

Match a pattern and save to variable using python

I have an output file containing thousands of lines of information. Every so often I find in the output file information of the following formInput Orientation: ... content ... Distance matrix (angstro…

Sharing a Queue instance between different modules

I am new to Python and I would like to create what is a global static variable, my thread-safe and process-safe queue, between threads/processes created in different modules. I read from the doc that t…

Square a number with functions in python [duplicate]

This question already has answers here:What does it mean when the parentheses are omitted from a function or method call?(6 answers)Closed last year.This is an extremely easy question for Python. Its…

Changing the cell name

I have a file that contains the following:NameABCD0145ABCD1445ABCD0998And Im trying to write a cod that read every row and change the name to the following format:NameABCD_145ABCD_1445ABCD_998keeping i…