Home > Back-end >  Creating a Entry box which outputs to a textbox in tkinter, python
Creating a Entry box which outputs to a textbox in tkinter, python

Time:02-04

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'.

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.

CodePudding user response:

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)
  • Related