I'm trying to make an Entry with a limit of 16 characters. So far I have something like this:
import tkinter as tk
rt = tk.Tk()
def tr_input():
a = e['textbox']
b = a.get()
print(b)
if "\b" in b:
return True
if "\n" in b:
calculate()
elif len(b)>16:
return False
return True
e = { "textbox":tk.Entry(rt,validate = "all",validatecommand=tr_input) }
calculate()
performs a calculation on numbers in the Entry, and displays it in another Label
It works fine, and prevents any further characters from being entered after the 16th one. However, it also prevents characters from being removed via backspace, and I can't figure out how to... not have it do that.
Does anyone know how I can fix this?
Edit: Specifically, I need to be able to find out if the last button pressed was backspace