Skip to main content

A Python module to display credits on pressing CTRL + O

Project description

Credito


Credito is a program to make instant credits in any Python app.

pip install credito


License

This project is licensed under the GNU General Public License v3.0 (GPLv3). See LICENSE for details.


Documentation

Install with:

pip3 install credito pip install credito

Configure and Use credito:

1. Import and Configure the Module:

You can import credito from the credito package and configure it with the path to your custom credits.cfg file. If you don’t specify a path, the default credits.cfg file included in the package will be used.

from credito import Credito

# Create an instance of Credito
credito = Credito()

# If you put nothing in the brackets then it will
# automatically use the default credits.cfg file included in the package.
credito.config()
# Or,
# Configure with a custom credits.cfg file
credito.config('path/to/your/custom/credits.cfg')

2. Start the Handler:

To start listening for the key combination (CTRL + O) and display the credits, you can call the handler function.

credito.handler()

3. Run the Module:

To have credito run in the background and listen for the key combination, you can run it as a standalone script or integrate it into your application.

If running as a standalone script, you can simply execute:

python -m credito

Or, integrate it into your application by calling the handler function as shown above.


How the Printing Works:

1. Configuration (credito.config):

  • When you call credito.config("path/to/custom/credits.cfg"), it loads the content of the credits.cfg file into memory by reading it and storing the content in the self.credits variable.
  • If you don't pass a path to the config function, it will use the default credits.cfg file included in the package.

2. Keypress Handler(handler):

  • When the CTRL + O key combination is detected by the listen_for_keypress function, it triggers the handler() function. The handler() function, in turn, calls credito.show_credits().

3. Displaying Credits (show_credits):

  • Inside show_credits(), the console is cleared using os.system('cls' if os.name == 'nt' else 'clear'), and then the content of self.credits (which contains the content from credits.cfg) is printed.
  • The program pauses for 10 seconds (time.sleep(10)), allowing the user to see the credits, and then it optionally clears the screen again.

Additional Notes

Running in Background:

  • The listen_for_keypress function runs in a separate thread, so the main program remains responsive. Make sure to handle this appropriately in your application.

No cross platform:

  • Don't ask me to add cross platform. I am way too busy to be doing that. It might work cross platform it's just I can't test it and it might not be reliable. Credito was made to work for Windows only. The example provided is tailored for Windows using ctypes. If you need cross-platform support, you may need to use different libraries or methods to handle global keypress events on other operating systems.

Permissions:

  • Capturing global keypresses might require administrative or elevated permissions depending on the system and environment.

Credits printing:

  • Credito will print everything in the credits.cfg file. The credits.cfg file is like a text document for Credito. Make sure the file has the content you want to display, and that it is correctly loaded into the config using the method shown in the documentation above. The Credits will allways be visible for 10 seconds, then either the console will clear again, or the terminal application will resume as normal.

What is the default/auto config?

Thank you for using our application!

Credits:
- Developer: Your Name
- Support: support@example.com

Enjoy using our software!
  • I chose this so it could be a template for easy testing. You are free to copy and change the default/auto config.

Directory Structure:

credito/ - # Base directory
├── credito/ - # Main package folder
│   ├── __init__.py - # Initializes the package
│   ├── credito.py - # Contains the Credito class and logic
│   └── data/ - # Contains seperate info
│       └── credits.cfg - # Default credits file 
├── tests/ - # Tests folder
│   ├── __init__.py - # Can be empty or contain shared fixtures
│   ├── conftest.py - # Global fixtures and hooks for tests
│   ├── test_credito.py - # Unit tests for Credito class
├── README.md - # Project description
├── setup.py - # Setup script for packaging
└── LICENSE - # Obviously just a license

âš¡ Quote
"Talk is cheap. Show me the code."
-- Linus Torvalds --


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

credito-3.2.5.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

credito-3.2.5-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

Details for the file credito-3.2.5.tar.gz.

File metadata

  • Download URL: credito-3.2.5.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for credito-3.2.5.tar.gz
Algorithm Hash digest
SHA256 ffb861a37a9f99878320330eceeed0069794e6bbfb5817d537b79eed9da8dffb
MD5 3f4dd9720c72e147d2e84b4fcfc3c27f
BLAKE2b-256 eea06eff669bfd91fc905ae43706e8f10358f8b3c6d7d5886d5db8e53e15a6b4

See more details on using hashes here.

File details

Details for the file credito-3.2.5-py3-none-any.whl.

File metadata

  • Download URL: credito-3.2.5-py3-none-any.whl
  • Upload date:
  • Size: 18.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for credito-3.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 0b10a4c7fa836126f1cac3f8673de9a95b3e996f4186d655985bd8b511eb3327
MD5 b3964b6269b7a3b82b1d06d85516b941
BLAKE2b-256 a523324f9b0b862c90366e2aab469ae1f72079bfbd0c7a1788f82447c2e74dba

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