Apr-21-2020, 01:48 PM
This part of Your code:
is trying to bind Tkinter's 'Entry' object, not your widget.
With entries in a loop like this,
create a list or dictionary prior to entering loop, and append each entry to the list, add the binding to each element as appended.
If you use a dictionary, you can append a key to each entry which will aid you if you need to change the configuration for an individual entry some time in the future.
Example (this for buttons, but concept is the same):
Entry(r_frm, bd=1, relief='solid', justify='center', width=4).grid(row=r, column=c) Entry.bind('<Button-3>', call_top)the Entry widget does not have a name, therefore the bind statement
Entry.bind('<Button-3>', call_top)
is trying to bind Tkinter's 'Entry' object, not your widget.
With entries in a loop like this,
create a list or dictionary prior to entering loop, and append each entry to the list, add the binding to each element as appended.
If you use a dictionary, you can append a key to each entry which will aid you if you need to change the configuration for an individual entry some time in the future.
Example (this for buttons, but concept is the same):
self.buttons = {} for name in ['A', 'B', 'C']: self.buttons[name] = {} self.buttons[name]['name'] = name self.buttons[name]['button'] = tk.Button(self.f2, fg="green", text=f"Solve for {name}") self.buttons[name]['button'].bind('<Button-1>', lambda event, bname=self.buttons[name]['name']: self.solve_equation(event, bname)) self.buttons[name]['button'].pack(side=tk.LEFT)