Python Tkinter :Удалить последний символ строки

Я делаю запись, которая позволяет вводить только цифры. В настоящее время я застрял на удалении только что введенного символа, если этот символ не является целым числом. Если кто-то заменит «Пустой» тем, что там нужно, это очень поможет.

import Tkinter as tk

class Test(tk.Tk):

    def __init__(self):

        tk.Tk.__init__(self)

        self.e = tk.Entry(self)
        self.e.pack()
        self.e.bind("<KeyRelease>", self.on_KeyRelease)

        tk.mainloop()



    def on_KeyRelease(self, event):

        #Check to see if string consists of only integers
        if self.e.get().isdigit() == False:

            self.e.delete("BLANK", 'end')#I need to replace 0 with the last character of the string

        else:
            #print the string of integers
            print self.e.get()




test = Test()
5
задан Cœur 31 August 2017 в 18:34
поделиться