Skip to main content

tkvalidate

Validation functions that only allow integers or floats for tkinter Entry widgets

The validate functions are called with an Entry widget as an argument. The following code will validate an Entry so only integers in the range -5 to 5 may be entered.

import tkinter as tk

root = tk.Tk()
widget = tk.Entry(root, justify=tk.CENTER)
widget.pack(padx=10, pady=10)
int_validate(widget, from_=-5, to=5)
root.mainloop()

This works on any subclass of Entry. For a ttk.Spinbox it can take the limits directly from the Spinbox. The following code accomplishes the same as the previous but with a Spinbox.

import tkinter as tk
from tkinter import ttk

root = tk.Tk()
widget = ttk.Spinbox(root, justify=tk.CENTER, from_=-5, to=5)
widget.pack(padx=10, pady=10)
int_validate(widget)
root.mainloop()

For validating floating points instead of integers, simply use float_validate instead.

Release files for tkvalidate 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tkvalidate 1.0.1
File Size Uploaded
tkvalidate-1.0.1.tar.gz 3.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tkvalidate 1.0.1
File Interpreter ABI Platform
tkvalidate-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.0 kB

Release files / tkvalidate-1.0.1.tar.gz

Download URL tkvalidate-1.0.1.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
28c2ee08f12f45844c1dd0d92c35c006d6d21f48db1f3fe8f4544a2d91b6da3d
BLAKE2b-256 checksum
How to use checksums
b3b7e339c986dc0751b8893e1b10eecb808a12e206b57be78a506cd6bd13ee9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Release files / tkvalidate-1.0.1-py3-none-any.whl

Download URL tkvalidate-1.0.1-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
781dbf52a3b8426ad9a5a0652fc1a0e47a51cccd85576aa90e20f746fdf73bff
BLAKE2b-256 checksum
How to use checksums
215f9e0580621aa5932418d02ce1b6c8ef9b40a6eca845106bc787894ec8d54f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page