Hi all i am new at python programming I have been trying to make an Tkinter project
I wanted to when i clicked on a button the data from my entrys go to the tabels and their special coulmns but while I click on the button this error appears: TypeError: ‘Event’ object is not subscriptable
"""
I made this app to help institutes to manage and register people without paper and ink
hopefully you can use it good and just do not forget to write number for customers age
or else we cant recognise your customer
enjoy!
"""
from tkinter import *
from tkinter import messagebox
from tkinter import ttk
# functions
def Reg(e):
if Name.get() != "" and Family.get() != "" and Age.get() != "":
reg.configure(state=NORMAL)
else:
reg.configure(state=DISABLED)
def regpressed(user):
if Age.get() < str(18):
messagebox.showwarning("warning!",
"we could not complete your register please come back when your sober and older")
return False
else:
ask = messagebox.askyesno("are you sure?", "Do you wish to proceed?")
if ask:
messagebox.showinfo("info", "we have done your registration")
# Screen.destroy()
return True
def Delete(e):
for item in e:
item.set("")
def idontknow():
esm = Name.get()
famil = Family.get()
sen = Age.get()
us = {"Name": Name, "family name": Family, "age": Age}
result = regpressed(us)
if result:
list = [name, family, age]
insert(list)
Delete(list)
Name.focus_set()
def Select(e):
selection_row = tbl.selection()
if selection_row != ():
name.set(tbl.item([selection_row])["values"][0])
def insert(value):
tbl.insert('', "end", value=[value[0].get(), value[1].get(), value[2].get()])
# new window and making it personal
Screen = Tk()
Screen.title("Underground gym")
Screen.geometry("%dx%d+%d+%d" % (900, 450, 200, 200))
# variable
name = StringVar()
family = StringVar()
age = StringVar()
# now we use labels
lbl = Label(Screen, text="Name:")
lbl.configure(font="normal 15 bold")
lbl.place(x=300, y=50)
lbl1 = Label(Screen, text="FamilyName:")
lbl1.configure(font="normal 15 bold")
lbl1.place(x=300, y=90)
lbl2 = Label(Screen, text="Age:")
lbl2.configure(font="normal 15 bold")
lbl2.place(x=300, y=130)
# Entry
Name = Entry(Screen)
Name.bind("<KeyRelease>", Reg)
Name.configure(width=25, justify="right", textvariable=name)
Name.place(x=370, y=57)
Family = Entry(Screen)
Family.bind("<KeyRelease>", Reg)
Family.configure(width=25, justify="right", textvariable=family)
Family.place(x=430, y=97)
Age = Entry(Screen)
Age.bind("<KeyRelease>", Reg)
Age.configure(width=15, textvariable=age, justify="right")
Age.place(x=350, y=137)
# now we make our buttons
reg = Button(Screen, text="Register")
reg.bind("<Button-1>", insert)
reg.configure(bg="aqua", padx=10, pady=5, state=DISABLED, command=idontknow)
reg.place(x=300, y=200)
# Tabel
tbl = ttk.Treeview(Screen, columns="c1, c2, c3", show="headings", height=90)
tbl.bind("<Button-1>", Select)
tbl.column("# 1", width=50)
tbl.heading("# 1", text="Name")
tbl.column("# 2", width=90)
tbl.heading("# 2", text="FamilyName")
tbl.column("# 3", width=50)
tbl.heading("# 3", text="Age")
tbl.pack(side=LEFT, fill=BOTH)
Screen.mainloop()
[quote=“martin, post:1, topic:60017, username:smart”]
else:
ask = messagebox.askyesno("are you sure?", "Do you wish to proceed?")
if ask:
messagebox.showinfo("info", "we have done your registration")
# Screen.destroy()
return True
Any Way I really appreciate it if you can help me