Skip to main content

A tkinter widget

Project description

DoubleScale

A tkinter widget that displays two cursors on a slider, to select two values.

Install

pip install tk-double-scale

Signature

DoubleScale.get_values()				# -> [float, float]
DoubleScale.set_values(a: float, b: float)

Arguments

master: tk.Widget
from_: float      	# value min
to: float         	# value max
length: int       	# widget length and thickness in pixels
thickness: int
cursor_width: int 	# cursor width
offset_x: int		# widget top left corner
offset_y: int
decimals: int		# values precision
bg_color: str		# color options
cursor_color: str
text_color: str
font: str			# font for the values displayed, can include any option
					# that a tkinter.font.Font would

Demo

import tkinter as tk
from tk_double_scale import DoubleScale


root = tk.Tk()
root.title('DoubleScale testing')
root.geometry('300x500+1000+200')
root.configure(bg='grey')


# Demonstrating several possible arguments
DoubleScale(root).pack(pady=5)                      # Default parameters
DoubleScale(root, font='Calibri 20').pack(pady=5)   # Custom font
DoubleScale(root, from_=-10, to=10).pack(pady=5)    # Custom range
DoubleScale(root, to=1, decimals=-2).pack(pady=5)   # Custom decimals

# Custom colors
DoubleScale(root, cursor_color='blue', bg_color='#0ff', 
            text_color='blue').pack(pady=5)

# Small size
DoubleScale(root, length=50, thickness=10, cursor_width=5, 
            font='Calibri 8').pack(pady=5)

# Big size
scale = DoubleScale(root, length=200, thickness=30, cursor_width=30, 
                    font='Calibri 20')
scale.pack(pady=5)


# Demonstrating getting and setting values
print(scale.get_values())   # > [0, 100]

# Values are clamped inside the range defined by from_ and to
scale.set_values(-10, -10)
print(scale.get_values())   # > [0, 0]

scale.set_values(200, 200)
print(scale.get_values())   # > [100, 100]

# Values are rounded according to decimals (default is 0 decimals)
scale.set_values(25.123, 75.123)
print(scale.get_values())   # > [25.0, 75.0]

root.mainloop()

DoubleScale test

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

tk_double_scale-0.0.2.tar.gz (29.6 kB view details)

Uploaded Source

Built Distribution

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

tk_double_scale-0.0.2-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file tk_double_scale-0.0.2.tar.gz.

File metadata

  • Download URL: tk_double_scale-0.0.2.tar.gz
  • Upload date:
  • Size: 29.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for tk_double_scale-0.0.2.tar.gz
Algorithm Hash digest
SHA256 0eb46106081b9f6454ec52307838c0e7fd1d83de97256a63495df957b671b4b1
MD5 a7298343cb396bf04335339e29a07622
BLAKE2b-256 5747e8ce2c2d2a7b35189f3d97ab7b2f57ca9c489f912f573babedb74f009c0e

See more details on using hashes here.

File details

Details for the file tk_double_scale-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for tk_double_scale-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b4fa8bea1f4a2a017ffae4424962e0b79fb6b137ea6c2b5e7993bcccd8c5e1c6
MD5 7087cef088dfd02cdfc658cd37b9ef2e
BLAKE2b-256 a64505aa42e22b5fe11b18b5b1931ffa444c3e76d2a2a8228dfd1ccc3d0c3859

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