Skip to content

Latest commit

 

History

History
24 lines (17 loc) · 439 Bytes

allow-alphanumeric.md

File metadata and controls

24 lines (17 loc) · 439 Bytes
title description author tags
Allow Alphanumeric
A validation function to allow alphanumeric characters.
Legopitstop
validation,alphanumeric
from tkinter import Tk, Entry


def allow_alphanumeric(value):
    return value.isalnum() or value == ""


# Usage:
root = Tk()
root.geometry("200x200")

reg = root.register(allow_alphanumeric)
Entry(root, validate="key", validatecommand=(reg, "%P")).pack()

root.mainloop()