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.2.tar.gz (32.1 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.2-py3-none-any.whl (31.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tkstart-1.0.2.tar.gz
  • Upload date:
  • Size: 32.1 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.2.tar.gz
Algorithm Hash digest
SHA256 6efdca542387d021a3ec0b095ab09e84594e6b96d15fb17847e49160a7c8d464
MD5 c2a1e565e8c58fa4420c4ea344403143
BLAKE2b-256 40d0a343b2bb10fa500a1c00af428324bb7c1b6dbc729b92dd8bb37bb7ee1f59

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tkstart-1.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d8de23e09e7890e90fe30b8b39bb1bec55ea32d425e10e330fa0957bff910ebb
MD5 f0e66f1109af335c401795823778a906
BLAKE2b-256 28decca927ade13e0669ddce8fec696fbf6fa9a85ae164607450bb287f78be40

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