I am trying to insert into a text area the content of the first field of my form, through a submission button.
from tkinter import *
from tkinter import ttk
from tkinter import font
window = Tk()
window.title("Interface")
window.geometry('500x500')
window.configure(background = "gray")
def submit_new_record():
outarea.insert(END, group_id_entry.get())
# Define general text size
fontsize=15
gfont = font.Font(size=fontsize)
# Input area LABELS
group_id = Label(window, text="group_id", font=gfont)
group_id.grid(row=0, column=0, sticky=W)
description = Label(window, text="Description", font=gfont)
description.grid(row=1, column=0, sticky=W)
repositories = Label(window, text="Repositories", font=gfont)
repositories.grid(row=2, column=0, sticky=W)
# Input area ENTRY
group_id_entry = Entry(window, font=gfont)
group_id_entry.grid(row=0, column=1)
description_entry = Entry(window, font=gfont)
description_entry.grid(row=1, column=1)
repositories_entry = Entry(window, font=gfont)
repositories_entry.grid(row=2, column=1)
# Output area
outarea = Text(window, height=13, width=40)
outarea.grid(row=4, column=1)
# ************** Submit Button ************** #
#Create an instance of Style Object
style = ttk.Style()
#Configure the properties of the Buttons
style.configure('submit.TButton', font=(None, fontsize))
btn = ttk.Button(window ,text="Submit", style='submit.TButton', command=submit_new_record())
btn.grid(row=5,column=0)
window.mainloop()
I thought that calling .insert()
in the text box was enough to print the .get()
value of the first field group_id_entry
.
However, clicking the submission button does not return the value of the first field in the text box.