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.4.tar.gz (33.8 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.4-py3-none-any.whl (33.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tkstart-1.0.4.tar.gz
  • Upload date:
  • Size: 33.8 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.4.tar.gz
Algorithm Hash digest
SHA256 5e2fb194f732fccfb7e91a872e0094a228983db4008d32023e145de2242059d7
MD5 827036357c22170fd2bc29fa66dabf6c
BLAKE2b-256 77980f4a6fe8b9e7fa3ea516bdcee01803dfd9419db5e42df3a5f84b1c581e18

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tkstart-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 33.2 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 fc58d38137b750a38b332d50a578aff973d8c62db15aa47fe941d96f22e9b8e5
MD5 645da6aa9f02861a76d5376b6957aead
BLAKE2b-256 405c0a62e2a000bc2ee69ff881f66df0995400d2cc870aae060e28feae176b3c

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