Skip to main content

HsPyLib - QT framework extensions

Project description

HomeSetup Python Library - HsPyLib

Your Python code is not JUST a script !!

License Release PyPi GitHub Gitter Donate

HsPyLib is a Python library that will elevate your experience to another level. It relies on well known principles as SOLID, DRY (Don't Repeat Yourself), KISS (Keep It Simple, Stupid) and YAGNI (You Ain’t Gonna Need It). It provides many frameworks and facilities to help you create mature python3 applications "PYCSNBASS" (Python Code Should Not Be A Simple Script).

HsPyLib is a part of the HomeSetup project.

Highlights

  • Easy installation.

  • Application manager that provides a helper to scaffold your python applications.

  • Widgets manager that provides running 'built-in' and custom python widgets.

  • Enhanced TUI helpers and input methods, to elevate your UXP with terminal applications.

  • crud framework to help with databases, repositories and services.

  • HTTP request helpers.

  • Enable Properties and AppConfigs using the most common extensions such as .properties, toml, yml...

  • Well tested code and often pylint clean.

  • Gradle build system with many extensions.

  • Various demos to help understand the library.

  • A Kafka manager application tool.

  • A Cloud Foundry application tool.

  • A Firebase application tool.

  • A Vault provider tool.

  • A CLI Terminal framework.

  • A PyQt applications framework.

Create an easy to use and code multiple select or choose input method:

from hspylib.modules.cli.vt100.vt_color import VtColor

from clitt.core.icons.font_awesome.nav_icons import NavIcons
from clitt.core.tui.mselect.mselect import mselect
from clitt.core.tui.tui_preferences import TUIPreferences


class SelectableItem:
    def __init__(self, name: str, value: str):
        self.name = name
        self.value = value

    def __str__(self):
        return f"Name: {self.name} Value: {self.value}"

    def __repr__(self):
        return str(self)


if __name__ == "__main__":
    TUIPreferences(
        max_rows=10,
        highlight_color=VtColor.WHITE,
        selected=NavIcons.SELECTED,
        unselected=NavIcons.UNSELECTED,
    )
    quantity = 22
    digits = len(str(quantity))
    it = [SelectableItem(f"Item-{n:>0{digits}}", f"Value-{n:>0{digits}}") for n in range(1, quantity)]
    sel = mselect(it)
    print(str(sel))

MenuSelect

from hspylib.modules.cli.vt100.vt_color import VtColor

from clitt.core.tui.mchoose.mchoose import mchoose
from clitt.core.tui.tui_preferences import TUIPreferences


class ChooseableItem:
    def __init__(self, name: str, value: str):
        self.name = name
        self.value = value

    def __str__(self):
        return f"Name: {self.name} Value: {self.value}"

    def __repr__(self):
        return str(self)


if __name__ == "__main__":
    TUIPreferences(
        max_rows=10, highlight_color=VtColor.WHITE
    )
    quantity = 22
    digits = len(str(quantity))
    it = [ChooseableItem(f"Item-{n:>0{digits}}", f"Value-{n:>0{digits}}") for n in range(1, quantity)]
    sel = mchoose(it)
    print(str(sel))

MenuChoose

Create beautiful form inputs:

from clitt.core.tui.minput.input_validator import InputValidator
from clitt.core.tui.minput.minput import MenuInput, minput

if __name__ == "__main__":
    # fmt: off
    form_fields = MenuInput.builder() \
        .field() \
            .label('letters') \
            .validator(InputValidator.letters()) \
            .build() \
        .field() \
            .label('word') \
            .validator(InputValidator.words()) \
            .build() \
        .field() \
            .label('number') \
            .validator(InputValidator.numbers()) \
            .min_max_length(1, 4) \
            .build() \
        .field() \
            .label('masked') \
            .itype('masked') \
            .value('|##::##::## @@') \
            .build() \
        .field() \
            .label('selectable') \
            .itype('select') \
            .value('one|two|three') \
            .build() \
        .field() \
            .label('checkbox') \
            .itype('checkbox') \
            .build() \
        .field() \
            .label('password') \
            .itype('password') \
            .validator(InputValidator.anything()) \
            .min_max_length(4, 8) \
            .build() \
        .field() \
            .label('read-only') \
            .access_type('read-only') \
            .value('READ-ONLY') \
            .build() \
        .build()
    # fmt: on

    result = minput(form_fields)
    print(result.__dict__ if result else "None")

MenuInput

Or even create nice dashboards:

from hspylib.modules.cli.vt100.vt_color import VtColor

from clitt.core.icons.font_awesome.dashboard_icons import DashboardIcons
from clitt.core.tui.mdashboard.mdashboard import mdashboard, MenuDashBoard
from clitt.core.tui.tui_preferences import TUIPreferences

if __name__ == "__main__":
    TUIPreferences(
        max_rows=10,
        items_per_line=3,
        highlight_color=VtColor.WHITE
    )
    # fmt: off
    dashboard_items = MenuDashBoard.builder() \
        .item() \
            .icon(DashboardIcons.POWER) \
            .tooltip('Do something') \
            .on_trigger(lambda: print('Something')) \
            .build() \
        .item() \
            .icon(DashboardIcons.MOVIE) \
            .tooltip('Another something') \
            .on_trigger(lambda: print('Another')) \
            .build() \
        .item() \
            .icon(DashboardIcons.NOTIFICATION) \
            .tooltip('Notify something') \
            .on_trigger(lambda: print('Notification')) \
            .build() \
        .item() \
            .icon(DashboardIcons.LIST) \
            .tooltip('List everything') \
            .on_trigger(lambda: print('List')) \
            .build() \
        .item() \
            .icon(DashboardIcons.DATABASE) \
            .tooltip('Database console') \
            .on_trigger(lambda: print('Database')) \
            .build() \
        .item() \
            .icon(DashboardIcons.EXIT) \
            .tooltip('Exit application') \
            .on_trigger(lambda: print('Exit')) \
            .build() \
        .build()
    # fmt: on

    result = mdashboard(dashboard_items)

MenuDashboard

Table of contents

Installation

Requirements

Python

  • Python 3.10 and higher

Operating Systems

  • Darwin
    • High Sierra and higher
  • Linux
    • Ubuntu 16 and higher
    • CentOS 7 and higher
    • Fedora 31 and higher

You may want to install HsPyLib on other OS's and it will probably work, but there are no guarantees that it WILL ACTUALLY WORK.

Required software

The following software are required:

  • Git (To clone the github repository)
  • Gradle (To build the HsPyLib project)

There are some python dependencies, but they will be automatically downloaded when the build runs.

PyPi

To install HsPyLib from PyPi issue the command:

# python3 -m pip install hspylib

To upgrade HsPyLib use the command:

# python3 -m pip install hspylib --upgrade

Additional modules that can also be installed:

  • CLItt : # python3 -m pip install hspylib-clitt to install HsPyLib CLI terminal tools.
  • Firebase : # python3 -m pip install hspylib-firebase to install HsPyLib Firebase application.
  • Vault : # python3 -m pip install hspylib-vault to install HsPyLib Vault application.
  • CFMan : # python3 -m pip install hspylib-cfman to install CloudFoundry manager.
  • Kafman : # python3 -m pip install hspylib-kafman to install Kafka manager.
  • Datasource : # python3 -m pip install hspylib-datasource to install datasource helpers.
  • HQT : # python3 -m pip install hspylib-hqt to install HsPyLib PyQt framework.

GitHub

To clone HsPyLib into your local machine type the command:

# git clone https://github.com/yorevs/hspylib.git

Documentation

The API documentation can be found here

Contact

You can contact us using our Gitter community or using our Reddit.

Support HsPyLib

You can support HsPyLib by donating or coding. Fell free to contact me for details. When contributing with code change please take a look at our guidelines and code of conduct.

paypal

Sponsors

This project is supported by:

Thank you for your support <3 !!

Links

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

hspylib-hqt-0.9.4.tar.gz (21.3 kB view details)

Uploaded Source

Built Distribution

hspylib_hqt-0.9.4-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

Details for the file hspylib-hqt-0.9.4.tar.gz.

File metadata

  • Download URL: hspylib-hqt-0.9.4.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for hspylib-hqt-0.9.4.tar.gz
Algorithm Hash digest
SHA256 0894c43776f6f9c0f6e04a0ffc902581650f0b2d2a3bd5b920046a12bd4e62ef
MD5 234abbad727c9d679c2d8ec87b9708b6
BLAKE2b-256 d8f3961dc1c4d124b85ee40c1d02a0f1ec59db89b8fddc17fc07aee764f5ce80

See more details on using hashes here.

File details

Details for the file hspylib_hqt-0.9.4-py3-none-any.whl.

File metadata

  • Download URL: hspylib_hqt-0.9.4-py3-none-any.whl
  • Upload date:
  • Size: 24.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for hspylib_hqt-0.9.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f24064da070c5ff1fb6712931e63c7fa081452192517fae176ebbf4d174c3549
MD5 ec4b90e7cca51e1ea25090a148222a56
BLAKE2b-256 5dfa275641b6e4b8d1f7e357622db25b0d4e545ab418c731740804ffc8a545b8

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