line-ui
This is a small Python package to provide an API to a one-line user interface (like that in a calculator) for Python learners.
It provides the following features:
- output in the line (left, right or middle aligned).
- output in the console (the lower box), mainly for debugging.
- keyboard input.
- timer input (every second or every 0.05 seconds).
- schedule a call to a function a certain seconds later.
- make a beep.
With these a Python learner can make apps like: digital clock, the classic digit invaders game, slapjack, etc.
How to use
Here is a sample program using line UI that displays a counter, which is incremented every second or when the user presses the up arrow key.
from line_ui import *
n = 0
# called when the UI is ready for you. You can display the
# initial stuff here.
def on_ready():
draw_r(str(n)) # draw a right-aligned string in the line
# called every frame (0.05 seconds). As it is empty, you may
# as well just delete this function.
def on_update():
pass
# called every second
def on_second():
global n
n = n+1
draw_r(str(n))
# you can use print to print to the lower box
print("got abcde "+str(n))
beep() # make a beep
# called when the user presses a key
def on_key():
global n
# you can get the key as a str, e.g., you get "a" if A key was pressed.
k = get_key()
if k == "KEY_UP":
n = n+1
draw_r(str(n))
elif k==" ":
draw_l("X") # draw a left-aligned string
schedule(1, hide_x)# hide X in one second
elif k == "q":
stop() # use this to tell the app to quit
def hide_x():
draw_l(" ")
start() # must do this to kick start the app with the UI
Metadata
Release files for lineui 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lineui-0.1.2.tar.gz | 15.9 kB | Without provenance | Details for lineui-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lineui-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for lineui-0.1.2-py3-none-any.whl |
Total release size: 31.7 kB
Release files / lineui-0.1.2.tar.gz
| Download URL | lineui-0.1.2.tar.gz |
|---|---|
| Size | 15.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
777ba573f8da0e4161e84030008e391bbf602660ee08c7ffcc1a90f2e26d4c53
|
|
BLAKE2b-256 checksum How to use checksums |
30b0ce9b32c86300756dba47303fc8997923ff4d74488f763f0f1deb5a8fb641
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Release files / lineui-0.1.2-py3-none-any.whl
| Download URL | lineui-0.1.2-py3-none-any.whl |
|---|---|
| Size | 15.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
14d3626504504a2fd2f75fe00a93330d063f9db28762e7df8531df7c93bdb488
|
|
BLAKE2b-256 checksum How to use checksums |
81fe20fa26b0023da10c60db66cc09d38eb9496817e008696568e268742dcbc8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Security for lineui 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.