Skip to main content

A digital clock made in Python for the terminal, inspired by tty-clock and tock.

Project description

pTock

A digital clock for the terminal, inspired by tty-clock and tock. The main difference with this version is that it is written in Python, and my goal was primarily to learn as much as possible about the language itself.

Note: emulating all the features of tty-clock and tock is not a goal of this project.

Features

  • Efficient bitmap and diff-based drawing.
  • Timezone fetched fro mthe system using the timedatectl command 2.
  • Military time and second display toggling.
  • Color customization.
  • Positioned or centered clock.
  • Adjustable display size.
  • Synchronization with system clock seconds.
  • Do not require any particular Python library, only standard Python libs.
  • If the terminal size changed, it will adjusts the clock position automatically.

Installation and Dependencies

  1. The only requirement is to have Python 3 installed and the basic core libraries.

  2. It is already available in PyPi, so you only need to run pip to intall and ptock to start the clock, as below:

pip install python3-ptock
ptock -h

Usage

Usage: ptock [OPTIONS]

A digital clock for the terminal.

Options:
  -h, --help             show this help message and exit.
  -x, --x <X>            Horizontal 0-indexed position of top-left corner [default: 0].
  -y, --y <Y>            Vertical 0-indexed position of top-left corner [default: 0].
  -W, --width <WIDTH>    Font width in characters per tile [default: 2].
  -H, --height <HEIGHT>  Font height in characters per tile [default: 1].
  -s, --second           Display seconds.
  -m, --military         Display military (24-hour) time.
  -c, --center           Center the clock in the terminal. Overrides manual positioning.
  -C, --color <COLOR>    Change the color of the time [If none is given, random from 1 to 7].
  -v, --version          Show program's version number and exit.

Available commands with this feature flag set are:

  • q or Q or <ESC>: Exit.
  • s: Toggle second display.
  • m: Toggle military (24H) time.
  • c: Center the clock in the terminal.
  • 0..=7: Change to corresponding ANSI color.

References

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

python3_ptock-1.2.2.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

python3_ptock-1.2.2-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file python3_ptock-1.2.2.tar.gz.

File metadata

  • Download URL: python3_ptock-1.2.2.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for python3_ptock-1.2.2.tar.gz
Algorithm Hash digest
SHA256 cdc0d6e9860b20feedbc790537cbc20d050d9bd6d1e205881b58fe15c5a6b994
MD5 ab97fe1b6c85c1c897cf843b9491a4ff
BLAKE2b-256 e67333b41d59c70a53ef0e10dbb30d01631780917fb8933cf2974e2a64cf28aa

See more details on using hashes here.

File details

Details for the file python3_ptock-1.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for python3_ptock-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 16a78c3383c6b9187c6d7742b63f2c4156c61a81fb271ab053b0ceeeea164ac8
MD5 70f4542676a3b422833915de77f83017
BLAKE2b-256 3f4258ce6f3e28c92cb38f022d3605de658f36f2ed172655f9a7a605795bbb2c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page