Skip to main content

Small starter kit for tkinter: clipboard, window helpers, styled widgets, project templates.

Project description

tkstart

License: MIT Python

A small starter kit for tkinter: clipboard helpers, window positioning, image loading, styled widget factories, colour utilities, validators, theme presets, and a tiny library of project templates that bootstrap a new tkinter project in one line.

Installation

pip install tkstart

That single command installs tkstart and its three runtime dependencies (Pillow, psycopg2-binary, pyperclip) so the bundled templates run straight out of the box. Tkinter itself ships with Python.

To uninstall:

pip uninstall tkstart

If you also want to drop the pulled-in libraries (only do this if no other project of yours needs them):

pip uninstall tkstart Pillow psycopg2-binary pyperclip

Quick start

import tkinter as tk
import tkstart

root = tk.Tk()
root.geometry("400x300")
tkstart.center(root)               # position window on the primary screen
tkstart.set_icon(root, "icon.ico") # silently no-op if file is missing

tkstart.title(root, "Hello").pack(pady=20)
tkstart.button(root, "OK", command=root.destroy, primary=True).pack()

root.mainloop()

Templates

The package bundles a few starter snippets and three ways to load them:

Way Example What happens
Side-effect import import tkstart.a SQL schema → clipboard
Side-effect import import tkstart.b CRUD app code → clipboard
Short alias tkstart.sql() SQL schema → clipboard
Short alias tkstart.app() CRUD app code → clipboard
Generic call tkstart.copy_template("tk_login") named template → clipboard
Save to file tkstart.save_template("tk_minimal", "main.py") written to disk

Available templates:

  • crud_app — a tkinter CRUD application skeleton.
  • sql_schema — a matching PostgreSQL schema for the CRUD demo.
  • tk_minimal — minimal window with a button.
  • tk_login — login-screen starter.
>>> import tkstart
>>> tkstart.templates()
['crud_app', 'sql_schema', 'tk_login', 'tk_minimal']
>>> tkstart.copy_template("crud_app")
True

API overview

tkstart.clipboard

Function Purpose
copy(text) Write text to the system clipboard.
paste() Return current clipboard contents.
clear() Empty the clipboard.
last_resort_path() Path of the fallback file when all adapters fail.

Strategies tried in order: pyperclip → Windows API via ctypes → native CLI (clip.exe / pbcopy / xclip / xsel) → tkinter → file dump.

tkstart.window

Function Purpose
center(window) Position window in the centre of the primary screen.
maximize(window) Maximize using the most reliable per-platform call.
toggle_fullscreen(window, state=None) Toggle (or force) full-screen mode.
set_icon(window, path) Set window icon from .ico / .png.

tkstart.images

Function Purpose
load_image(path, size=None) Return a tkinter PhotoImage.
thumbnail(path, max_size=(128,128)) Return a downscaled thumbnail.

tkstart.widgets

Function Purpose
button(parent, text, ...) Styled tk.Button.
title(parent, text) Large-bold label.
separator(parent) Horizontal divider.
labeled_entry(parent, label) Row containing a label and an Entry.

tkstart.colors

Hex/RGB conversion plus lighten, darken, mix, luminance, is_dark, contrast_text.

tkstart.validation

Field validators returning None on success or an error string: required, min_length, max_length, is_email, is_phone, is_number, between.

tkstart.theme

A Theme dataclass plus LIGHT, DARK, SOFT presets. Use theme.apply(theme.DARK) to set the active theme.

tkstart.utils

Money formatting, date parsing, search-tolerant string helpers, file-name sanitisation.

Compatibility

  • Python 3.8 — 3.12
  • Windows, macOS, Linux

License

MIT

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

tkstart-1.0.3.tar.gz (32.2 kB view details)

Uploaded Source

Built Distribution

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

tkstart-1.0.3-py3-none-any.whl (31.4 kB view details)

Uploaded Python 3

File details

Details for the file tkstart-1.0.3.tar.gz.

File metadata

  • Download URL: tkstart-1.0.3.tar.gz
  • Upload date:
  • Size: 32.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for tkstart-1.0.3.tar.gz
Algorithm Hash digest
SHA256 ae50967b6b6969304a4c7521f19c349ae9ed7bfe7bca8589ba3bc961f433ac29
MD5 9be714e6676c0727963635afade47e88
BLAKE2b-256 c4c7a59c2e55cbb8e3473cfaad1ad7efe1269d437fdeb0d1abbc9a6b09180234

See more details on using hashes here.

File details

Details for the file tkstart-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: tkstart-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 31.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for tkstart-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 69014213bff9f3f92dd6d2e0d9672835531c63281e1b99a7b9264655f9eca710
MD5 f55d2891c9d94944a38ce206685514be
BLAKE2b-256 4598879d9ffa3b447b247f99ad916ea08d1bc1bc6a759bb47b97fe6c46c129d7

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