Skip to main content

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

Project description

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 input.

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tkvalidate-1.0.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tkvalidate-1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file tkvalidate-1.0.tar.gz.

File metadata

  • Download URL: tkvalidate-1.0.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for tkvalidate-1.0.tar.gz
Algorithm Hash digest
SHA256 1f2ebeaf17cd5f5e22dc12bfa27ece8fbc844355beac07cfc7822e8589985bf4
MD5 9f76929d1c6a8f82261b65cd0dfae41f
BLAKE2b-256 3f46b12926bd7f1780e1070480f441aeb35ea9ab2c3f0ef9619492e30887d4e4

See more details on using hashes here.

File details

Details for the file tkvalidate-1.0-py3-none-any.whl.

File metadata

  • Download URL: tkvalidate-1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for tkvalidate-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 68d8ee55b958bc4b9d0d9ebaf9a59e59ec4d1dc272f5d4bbd2faf493ca8f7477
MD5 92553455660e4aa14aa7729c667f69ae
BLAKE2b-256 c47b3acc50265087d3a73fb1cb05687b743c5c71b8714e60d63f1efa7bc19d5c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page