Skip to main content

A console ui interface

Project description

Schnittstelle

Installation

pip install schnittstelle

Import
# completer
from schnittstelle import Completer, CompleterStyle, RunnableCompleter

# loader
from schnittstelle import Loader, LoaderStyle, RunnableLoader

# decorators
from schnittstelle import decorators

Completer

[✓] complete
[X] fail

While completer is drawing to print use

completer.print('string to print')
  • Use

    with statement

    Recommended

      with Completer(message='Dummy bar') as completer:
        # code
        pass
    

    The object will auto complete when on exiting with statement

    You may also exit using completer.complete or completer.fail()

    Decorator
    from schnittstelle import decorators
    
    @decorators.Completer(message='foo bar')
    def foo(s):
        # code
    

    Everytime the function is called Completer will appear

    In case of exception it is caught and runs the fail method of completer

    Using this method you're not able to access completer class itself

    Inline
    completer = Completer().init()
    
    # code
    
    completer.complete() # or completer.fail()
    

    Exit the completer using completer.complete or completer.fail()

    Runnable

    Not recommended

    def foo(s):
      # code
    
    runnable = RunnableCompleter(foo, message='foo bar')
    runnable.run('foo')
    

    All arguments go into run method

    In case of exception it is caught and runs the fail method of completer

    Using this method you're not able to access completer class itself

  • Configuration

    • style

      Takes in class CompleterStyle

      CompleterStyle
      Static Constuctors

      default default settings

      Attributes

      prefix

      character before char

      default: [

      postfix

      character after char

      default: ]

      success

      color of character when successful

      default: GREEN

      error

      color of character when unsuccessful

      default: RED

      info

      color of character in info messages

      default: BLUE

Loader

This is the progress bar class of package

[==   ] Dummy bar

While the progress bar is in progress to print use

loader.print('string to print')
  • Use

    with statement

    Recommended

      with Loader(message='Dummy bar') as loader:
        # code
        pass
    

    The bar will auto complete when on exiting with statement

    You may also exit using loader.complete or loader.fail()

    Decorator
    from schnittstelle import decorators
    
    @decorators.Loader(message='foo bar')
    def foo(s):
        # code
    

    Everytime the function is called loader will appear

    In case of exception it is caught and runs the fail method of loader

    Using this method you're not able to access loader class itself

    Inline
    loader = Loader().init()
    
    # code
    
    loader.complete() # or loader.fail()
    

    Exit the progress bar using loader.complete or loader.fail()

    Runnable

    Not recommended

    def foo(s):
      # code
    
    runnable = RunnableLoader(foo, message='foo bar')
    runnable.run('foo')
    

    All arguments go into run method

    In case of exception it is caught and runs the fail method of loader

    Using this method you're not able to access loader class itself

  • Configurations

    To change the configurations at runtime use loader.brush.[configuration] syntax

    configurations need to be passed into class initiator as keyword arguments

    • value

      Current value of progress

      If this value is less than 0, the progress bar is indeterminate

    • total

      Total progress for the bar

    • message

      Message label to display on progress bar

      In the above example it is Dummy bar

    • frequency

      Number of refreshes per second

      This will determine the speed of the progress bar as well

      If frequency is too low, progress bar might not show progress as intended

      default is 20 refreshes per sec

    • style

      Takes in class LoaderStyle

      LoaderStyle
      Static Constuctors

      default default settings

      ascii only containing ascii chars

      Attributes

      width

      width of the progress bar

      default: 5

      cursor_width

      Fill width of indeterminate progress bar

      default: 3

      fill

      Fill indicator charactor

      default: FULL_BLOCK

      empty

      empty indicator charactor

      default: SPACE

      prefix

      character before progress bar

      default: [

      postfix

      character after progress bar

      default: ]

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

schnittstelle-0.1.0.tar.gz (9.5 kB view hashes)

Uploaded Source

Built Distribution

schnittstelle-0.1.0-py3-none-any.whl (14.6 kB view hashes)

Uploaded Python 3

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