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, and a tiny library of project templates. The package is dependency-free for its core; image helpers optionally use Pillow when installed.

Installation

pip install tkstart

Optional extras:

pip install tkstart[images]      # adds Pillow for richer image support
pip install tkstart[clipboard]   # adds pyperclip as the preferred adapter

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()

API overview

tkstart.clipboard

Function Purpose
copy(text) Write text to the system clipboard, returns bool.
paste() Return current clipboard contents as str.
clear() Empty the clipboard.

Strategies are tried in order: pyperclip (if installed) → native CLI (clip.exe / pbcopy / xclip / xsel) → tkinter fallback.

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, command=None, primary=False, danger=False) 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.templates

Ready-made starter snippets bundled with the package.

Function Purpose
templates() List available template names.
get_template(name) Return the raw text of a template.
copy_template(name) Copy the template to the system clipboard.
save_template(name, path=None) Save the template to a file.
print_template(name) Print the template to stdout.

Current templates:

  • crud_app — a tkinter CRUD application skeleton suitable as a starting point for course projects.
  • sql_schema — a matching PostgreSQL schema for the CRUD demo.
  • tk_minimal — a minimal window with a button.
  • tk_login — a login-screen starter.
>>> import tkstart
>>> tkstart.templates()
['crud_app', 'sql_schema', 'tk_login', 'tk_minimal']
>>> tkstart.copy_template("crud_app")        # then Ctrl+V in your editor
[tkstart] copied 'crud_app' (16953 chars)
>>> tkstart.save_template("sql_schema", "schema.sql")
[tkstart] saved 'sql_schema' (20550 chars) -> /full/path/schema.sql

Short aliases:

Short form Equivalent
tkstart.t(name) tkstart.copy_template(name)
tkstart.app() tkstart.copy_template("crud_app")
tkstart.sql() tkstart.copy_template("sql_schema")

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

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.1.tar.gz (31.7 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.1-py3-none-any.whl (30.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tkstart-1.0.1.tar.gz
  • Upload date:
  • Size: 31.7 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.1.tar.gz
Algorithm Hash digest
SHA256 a0b516aa92e873be3359d4b760b1351a2164d5b7bde0eda685c929865054ecd9
MD5 fba6571f5f069b6e7790b21ffbed04af
BLAKE2b-256 4d414f1a6d23278382ae140346c057bef0514c4de9eb43276b3a8059024dcb34

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tkstart-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 30.6 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6263f5b3475a2eed08448ae4f79854e502c44b8aafb246edd3878d83b784330e
MD5 f09942aa9068b95cb38c424a87b8bfc5
BLAKE2b-256 c1d4fe048cd28beb65619de55902835536aea70103740ec1e50fa7fcbe6cf3f1

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