A to create a better ui with your terminal.
Project description
Better Terminal
A simple pip library to make your terminal simpler
Documentation
Installation
pip install better_terminal
Creating a template
A template is just a simple string where you can add variables as placeholders.
from better_terminal import Terminal
terminal = Terminal.New("@RED@Launching Rocket in @BRIGHT_YELLOW@#countdown#.")
If you run the script now, the place holder will stay as it is.
To change that we need to create variable for those place holder.
[NOTE: Notice the @ colors @, we will talk about that later]
Creating variables
.create_variable() requires two arguments, the name of the placeholder and a default value for the variable.
countdown = terminal.create_variable("countdown", 5)
As soon as we create the variable the placeholders will automatically update.
Using the variable
You can get the current value of the variable with .value method
print(variable.value)
To update the variable use .update() which requires one argument, that is the new value of the variable
Lets see an example with a simple countdown
while True:
sleep(2)
countdown.update(countdown.value - 1)
if(countdown.value == 0):
terminal.update_template("@GREEN@ROCKET LAUNCHED!")
sleep(10)
break
Yay!
Changing template
You don't need to be stuck with a sinple template. You can change your template with .update_template() function which accepts one arguemnt that is the new template.
Colors
Ever thought that terminals were boring, well lets decorate them with colors.
You can use the .COLOR["COLOR_NAME"] property of Terminal class to get or color string.
Terminal.New(Terminal.COLOR["GREEN"] + "Hello World")
This will change the text after color to green.\
[NOTE: There color value ever works with the variable value]\
Or you can just use the color name with "@"on both sides.
Terminal.New("@GREEN@Hello World")
To switch to the default color, use @CLEAR@ or Terminal.COLOR["CLEAR"].
Example Code
from better_terminal import Terminal
from time import sleep
terminal = Terminal.New("@RED@Launching Rocket in @BRIGHT_YELLOW@#countdown#.")
countdown = terminal.create_variable("countdown", 5)
while True:
sleep(2)
countdown.update(countdown.value - 1)
if(countdown.value == 0):
terminal.update_template("@GREEN@ROCKET LAUNCHED!")
sleep(10)
break
License
We use the MIT License for this project
FAQ
When will be the next update?
Quite Soon
When will the new update bring?
The new update will bring integration of terminal input with the whole system.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file better_terminal-0.0.0.tar.gz
.
File metadata
- Download URL: better_terminal-0.0.0.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f910ae5a0c9c3dd42953507f090c73790d2c78b510f813fdfc507cb91fc03075 |
|
MD5 | ed22c5dfbc1e33491f938470d72f767f |
|
BLAKE2b-256 | 58c53be306c9ec343e8297bc37f9ece521ae5896a27165d72c4332bc01f62399 |
File details
Details for the file better_terminal-0.0.0-py3-none-any.whl
.
File metadata
- Download URL: better_terminal-0.0.0-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6833a598e5651bf092a39e4f626a24bea1097adc78a9dbe5b58228c45e5fc33e |
|
MD5 | 2d0cbdcbf58df158bba91ff82eb803aa |
|
BLAKE2b-256 | 6a030c7200d255cb07c2663a6209e256c35aa6af0c3e975a1742c4bc563be439 |