Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Creating a Entry box which outputs to a textbox in tkinter, python

I’m encountering difficulties when trying to use the entrybox within tkinter, i’ve tried a few online resources and none seem to help my exact issue. So my interface is mainly complete, but I couldn’t cover everything.

Terefor wanted to add a small entry box, which allowed users to type in custom code and commands. The output of these commands would be displayed in a different text box, just below (or as a pop-up, but havent figured this one out yet!). I’m getting an assortment of errors and have tried doing this multiple ways. Currently the code looks like the following.

Entry1 = Entry(master, width=50)
Entry1.grid(row=2, column=29, columnspan=3, rowspan=1)
labelT = Label(master, text='             ')
labelT.grid(row=2, column=25, columnspan=3, rowspan=1)

txt7 = Text(master, width=40, height=10, wrap=WORD)
txt7.grid(row=5, column=29, columnspan=3, rowspan=1)

def Run_custom():
    txt7.delete(0.0, END)
    CustomText = (Entry1.get(0.0, END))
    Entry1.delete(0.0, END)
    txt7.insert(0.0, CustomText)
    

button2 = Button(master, text="Run custom", command=Run_custom)
button2.grid(row=2, column=34, columnspan=3, padx=40, pady=10)

The current error i’m getting is ‘TypeError: get() takes 1 positional argument but 3 were given’.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Any help would be fantastic thanks!

Expecting when inputing a command in, the output of the command to appear in the text box below. Instead error message.

>Solution :

try this it should solve your problem:

def Run_custom():
    txt7.delete(0.0, END)
    CustomText = Entry1.get()
    Entry1.delete(0.0, END)
    txt7.insert(0.0, CustomText)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading