Code Monkey home page Code Monkey logo

quo's Introduction

Downloads PyPI version Wheel Windows Build Status pyimp RTD DOI licence Twitter Follow

Logo

Forever Scalable

Quo is a toolkit for writing Command-Line Interface(CLI) applications and a TUI (Text User Interface) framework for Python.

Quo is making headway towards composing speedy and orderly CLI and TUI applications while forestalling any disappointments brought about by the failure to execute a python application. Simple to code, easy to learn, and does not come with needless baggage.

Compatibility

Quo works flawlessly with Linux, OSX, and Windows. Quo requires Python 3.8 or later.

Features

  • Support for Ansi, RGB and Hex color models
  • Support for tabular presentation of data
  • Intuitive progressbars
  • Code completions
  • Nesting of commands
  • Customizable Text User Interface (TUI) dialogs.
  • Automatic help page generation
  • Syntax highlighting
  • Autosuggestions
  • Key Binders

Getting Started

Installation

You can install quo via the Python Package Index (PyPI)

pip install -U quo

In order to check your installation you can use

python -m pip show quo

Run the following to test Quo output on your terminal:

python -m quo

test

💡 press Ctrl-c to exit

Quo Library

Quo contains a number of builtin features you c an use to create elegant output in your CLI.

Quo echo

To output formatted text to your terminal you can import the echo method. Try this:

Example 1

 from quo import echo

 echo("Hello, World!", fg="red", italic=True, bold=True)

Example 2

 from quo import echo

 echo("Blue on white", fg="blue", bg="white")
 

Alternatively, you can import print

Example 1

 from quo import print

 print('<b>This is bold</b>')
 print('<i>This is italic</i>')

Example 2

 from quo import print

 print('<u>This is underlined</u>')
 

Example 3

 from quo import print

 print("Quo is <style bg='red'>Scalable</style>") 

Example 4

 # Colors from the ANSI palette.
 print('<red>This is red</red>')
 print('<style fg="white" bg="green">White on green</stlye>')

Quo prompt

  • Using quo.prompt method.
 from quo.prompt import prompt

 prompt("What is your name?")

  • Using quo.prompt.Prompt object

Example 1

 from quo.prompt import Prompt
   
 session = Prompt()
 session.prompt("Type something:") 

Example 2 Colored Prompt

 from quo.prompt import Prompt
   
 session = Prompt()
 session.prompt("<red>Type something: </red>") 

Example 3 Example upgrade

  from quo.prompt import Prompt

  session = Prompt(fg="blue") #The input will be colored blue

  session.prompt("<red>john</red><white>@</white><green>localhost</green><red>:</red><cyan><u>/user/john</u></cyan><purple>$ </purple>")

styled

Example 4 Bottom toolbar

from quo.prompt import Prompt

session = Prompt()

session.prompt('> ', bottom_toolbar="<i>This is a</i><b><style bg='red'> Toolbar</style></b>")

Bottom toolbar

Example 5

Here's an example of a multiline bottom toolbar.

from quo.prompt import Prompt

session = Prompt()

session.prompt("Say something: ", bottom_toolbar="This is\na multiline toolbar")

Bottom toolbar

Example 6

Placeholder text

A placeholder text that's displayed as long as no input s given.

💡 This won't be returned as part of the output.

  from quo.prompt import Prompt

  session = Prompt() 
  session.prompt("What is your name?: ", placeholder='<gray>(please type something)</gray>')

Example 7

Coloring the prompt.

from quo.prompt import Prompt

session = Prompt(fg="red")
session.prompt("Type something: ")

Example 8

Autocomplete text

Press [Tab] to autocomplete

 from quo.prompt import Prompt
 from quo.completion import WordCompleter
 example = WordCompleter(['USA', 'UK', 'Canada', 'Kenya'])
 session = Prompt(completer=example)
 session.prompt('Which country are you from?: ')

Autocompletion

Example 9

Autosuggest text

Auto suggestion is a way to propose some input completions to the user. Usually, the input is compared to the history and when there is another entry starting with the given text, the completion will be shown as gray text behind the current input. Pressing the right arrow → or ctrl-e will insert this suggestion, alt-f will insert the first word of the suggestion.

 from quo.history import MemoryHistory
 from quo.prompt import Prompt

 MemoryHistory.append("import os")
 MemoryHistory.append('print("hello")') 
 MemoryHistory.append('print("world")')  
 MemoryHistory.append("import path")

 session = Prompt(history=MemoryHistory, suggest="history")

 while True:
    session.prompt('> ')

Read more on Prompt

Quo Bar

Draw a horizontal bar with an optional title, which is a good way of dividing your terminal output in to sections.

 from quo.bar import Bar

 bar = Bar("I am a bar")
 bar.draw()

  • Styled bar
 from quo.bar import Bar

 bar = Bar("I am a styled bar")
 bar.draw(fg="blue", bg="yellow")

  • Right aligned
 from quo.bar import Bar
   
 bar = Bar("I am right aligned")
 bar.draw(align="right")

Quo Console

For more control over quo terminal content, import and construct a Console object.

Launching Applications

Quo supports launching applications through Console.launch

Example 1

 from quo.console import Console

 console = Console()
 console.launch("https://quo.rtfd.io/")

Example 2

 from quo.console import Console

 console = Console()
 console.launch("/home/path/README.md", locate=True)

Spin🔁

Quo can create a context manager that is used to display a spinner on stdout as long as the context has not exited

 import time
 from quo.console import Console

 console = Console()

 with console.spin():
           time.sleep(3)
           print("Hello, World")

Read more on Console

Quo Dialogs

High level API for displaying dialog boxes to the user for informational purposes, or to get input from the user.

Example 1

Message Box dialog

 from quo.dialog import MessageBox

 MessageBox(
    title='Message window',
    text='Do you want to continue?\nPress ENTER to quit.')

Message Box

Example 2

  • Input dialog
 from quo.dialog import InputBox

 InputBox(
     title='PromptBox Shenanigans',
     text='What Country are you from?:')

Input Box

  • Multiline Input dialog
 from quo.dialog import InputBox

 InputBox(
     title='PromptBox Shenanigans',
     text='What Country are you from?:',
     multiline=True)

Input Box

  • Password Input dialog
 from quo.dialog import InputBox

 InputBox(
     title='PromptBox Shenanigans',
     text='What Country are you from?:',
     hide=True)

Input Box

  • Radiolist
 from quo.dialog import RadiolistBox

 RadiolistBox(
     title="RadioList dialog example",
     text="Which breakfast would you like ?",
     values=[
         ("breakfast1", "Eggs and beacon"),
         ("breakfast2", "French breakfast"),
         ("breakfast3", "Equestrian breakfast")
     ])

Radiolist

Read more on Dialogs

Quo Key Binding🔐

A key binding is an association between a physical key on akeyboard and a parameter.

 from quo import echo
 from quo.keys import bind
 from quo.prompt import Prompt

 session = Prompt()

 # Print "Hello world" when ctrl-h is pressed
 @bind.add("ctrl-h")
 def _(event):
      echo("Hello, World!")

 session.prompt("")

Read more on Key bindings

Quo Parser

You can parse optional and positional arguments with Quo and generate help pages for your command-line tools.

 from quo.parse import Parser
 
 parser = Parser(description= "This script prints hello NAME COUNT times.")

 parser.argument('--count', default=3, type=int, help='number of greetings')
 parser.argument('name', help="The person to greet")
 
 arg = parser.parse()
 
 for x in range(arg.count):
     print(f"Hello {arg.name}!")
   $ python prog.py John --count 4
   

And what it looks like:

Here's what the help page looks like:

 $ python prog.py --help

Read more on Parser

Quo ProgressBar

Creating a new progress bar can be done by calling the class ProgressBar The progress can be displayed for any iterable. This works by wrapping the iterable (like range) with the class ProgressBar

 import time
 from quo.progress import ProgressBar
  
 with ProgressBar() as pb:
               for i in pb(range(800)):
                             time.sleep(.01)

ProgressBar

Read more on Progress

Quo Rule

Used for drawing a horizontal line.

Example 1

 from quo.rule import Rule

 rule = Rule()
 rule.draw()

Example 2

  • A styled line.
 from quo.rule import Rule

 rule = Rule()
 rule.draw(color="purple")

Example 3

  • A multicolored line.
 from quo.rule import Rule

 rule = Rule()
 rule.draw(multicolored=True)

Quo Tables

This offers a number of configuration options to set the look and feel of the table, including how borders are rendered and the style and alignment of the columns.

Example 1

 from quo.table import Table
 
 data = [
    ["Name", "Gender", "Age"],
    ["Alice", "F", 24],
    ["Bob", "M", 19],
    ["Dave", "M", 24]
    ]

 table = Table(data)
 table.print()

tabulate

Example 2

Right aligned table

 from quo.table import Table

 data = [
    ["Name", "Gender", "Age"],
    ["Alice", "F", 24],
    ["Bob", "M", 19],
    ["Dave", "M", 24]
    ]

 table = Table(data)
 table.print(align="right")

tabulate

Example 3

Colored table

 from quo.table import Table

 data = [
    ["Name", "Gender", "Age"],
    ["Alice", "F", 24],
    ["Bob", "M", 19],
    ["Dave", "M", 24]
    ]
    
 table = Table(data)
 table.print(fg="green")

tabulate

Example 4

Column width

In situations where fields are expected to reasonably be too long to look good as a single line, parameter column_width can help automate word wrapping long fields.

 from quo.table import Table

 data = [
       [1, 'John Smith', 'This is a rather long description that might look better if it is wrapped a bit']
       ]

 table = Table(data)
 table.print(headers=("Issue Id", "Author", "Description"), column_width=[None, None, 30])

tabulate

Example 5

Grid table

from quo.table import Table

data = [
    ["Name", "Gender", "Age"],
    ["Alice", "F", 24],
    ["Bob", "M", 19],
    ["Dave", "M", 24]
   ]

table = Table(data)
table.print(theme="grid")

tabulate

Read more on Table

Quo Widgets

A collection of reusable components for building full screen applications.

Frame

Used draw a border around any container, optionally with a title.

Read more on Frame

Label

Widget that displays text.

Read more on Label

Box + Label

 from quo import container
 from quo.box import Box
 from quo.label import Label

 content = Label("Hello, World!", fg='red', bg='yellow')

 container(content)

Box

Read more on Widgets

For more intricate examples, have a look in the examples directory and the documentation.

Donate🎁

In order to for us to maintain this project and grow our community of contributors. Donate

Quo is...

Simple If you know Python you can easily use quo and it can integrate with just about anything.

Getting Help

Community

For discussions about the usage, development, and the future of quo, please join our Google community

Resources

Bug tracker

If you have any suggestions, bug reports, or annoyances please report them to our issue tracker at Bug tracker or send an email to:

📥 [email protected] | [email protected]

Blogs💻

→ How to build CLIs using quo

License📑

License: MIT
This software is licensed under the MIT License. See the License file in the top distribution directory for the full license text.

Code of Conduct

Code of Conduct is adapted from the Contributor Covenant, version 1.2.0 available at Code of Conduct

quo's People

Contributors

pyup-bot avatar quantum-quirks avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

quo's Issues

Initial Update

The bot created this issue to inform you that pyup.io has been set up on this repo.
Once you have closed it, the bot will open pull requests for updates as soon as they are available.

Missing dependency and .flair() function not available.

Describe the bug
wcwidth is a required module but deosn't get installed when installing quo via pip.
The examples refer to quo.flair() but it doesn't seem to have such a function

To Reproduce

import quo
quo.flair(f'Hello, World!', fg="red", bold=True)
Traceback (most recent call last):
File "", line 1, in
AttributeError: module 'quo' has no attribute 'flair'

Expected behavior
.flair() function should be available

Screenshots
image

Desktop (please complete the following information):

  • OS: Mac OSX Big Sur with Homebrew
  • Python 3.9.6 (installed via Homebrew).

unicode characters not displaying on windows

You may find a solution to your problem in the docs or issues.

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS, Ubuntu]
  • Version [e.g. 22]

Android(please complete the following information):

  • Model [e.g. Samsung]
  • OS: [eg. Android 11]
  • App [e.g. Termux]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Dialogs gives an error to start [BUG]

You may find a solution to your problem in the docs or issues.

Describe the bug
When i use the module quo.dialog i recived a some errors using a
template of the docs which are that:

Traceback (most recent call last):
  File "C:\Users\esteb\Downloads\Haciendouncliente\Launch(thanks-to-portablemc).py", line 4, in <module>
    MessageBox(
  File "C:\Users\esteb\scoop\apps\python\current\Lib\site-packages\quo\dialog.py", line 475, in MessageBox
    return _MessageBox(
           ^^^^^^^^^^^^
  File "C:\Users\esteb\scoop\apps\python\current\Lib\site-packages\quo\dialog.py", line 201, in _MessageBox
    dialog = Dialog(
             ^^^^^^^
  File "C:\Users\esteb\scoop\apps\python\current\Lib\site-packages\quo\widget\dialogs.py", line 88, in __init__
    body=Frame(
         ^^^^^^
  File "C:\Users\esteb\scoop\apps\python\current\Lib\site-packages\quo\widget\core.py", line 538, in __init__
    Label(
  File "C:\Users\esteb\scoop\apps\python\current\Lib\site-packages\quo\widget\core.py", line 388, in __init__
    FormattedTextControl(Text(text)),
                         ^^^^^^^^^^
  File "C:\Users\esteb\scoop\apps\python\current\Lib\site-packages\quo\text\html.py", line 31, in __init__
    mini = minidom.parseString(f"<html-root>{value}</html-root>")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\esteb\scoop\apps\python\current\Lib\xml\dom\minidom.py", line 2000, in parseString
    return expatbuilder.parseString(string)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\esteb\scoop\apps\python\current\Lib\xml\dom\expatbuilder.py", line 925, in parseString
    return builder.parseString(string)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\esteb\scoop\apps\python\current\Lib\xml\dom\expatbuilder.py", line 223, in parseString
    parser.Parse(string, True)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 36

Code:

import subprocess
from quo.dialog import MessageBox

MessageBox(
    title='Message window',
    text='Do you want to continue?\nPress ENTER to quit.')

To Reproduce
Steps to reproduce the behavior:

  1. Run the code up ☝️

Expected behavior
A clear and concise description of what you expected to happen.
I belive that a some argument (i don't know which) may be crashed by a error in the loading of the dialog and the core. I don't know, but i was looking in to source code and then i found the core (I don't know if this matters) and i found that would be outdated or simply broken.

Screenshots
If applicable, add screenshots to help explain your problem.
image
image

Desktop (please complete the following information):

  • OS: [e.g. Windows 11]
  • Version [e.g. 22H2 (KB5025305)]

Android(please complete the following information):

  • Model [e.g. Samsung]
  • OS: [eg. Android 11]
  • App [e.g. Termux]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.
I think is probably a problem of my computer should be my ssd that's may be no too high quality and i saw some problems to start apps and programs.

Initial Update

The bot created this issue to inform you that pyup.io has been set up on this repo.
Once you have closed it, the bot will open pull requests for updates as soon as they are available.

TypeError()

Describe the bug
TypeError: prompt() got an unexpected keyword argument 'autoconfirm'

Import error within package

Describe the bug
I tried to execute examples from README.md, this one is for prompt, however I get an ImportError

>>> completer = quo.completion.WordCompleter(['USA', 'UK', 'Canada', 'Kenya'])
>>> session = quo.Prompt(completer=completer)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python\Python38\lib\site-packages\quo\shortcuts\prompt.py", line 452, in __init__
    self.app = self._create_application(editing_mode, erase_when_done)
  File "C:\Python\Python38\lib\site-packages\quo\shortcuts\prompt.py", line 703, in _create_application
    application: Suite[_T] = Suite(
  File "C:\Python\Python38\lib\site-packages\quo\suite\suite.py", line 280, in __init__
    self.output = output or session.output
  File "C:\Python\Python38\lib\site-packages\quo\suite\current.py", line 70, in output
    self._output = create_output()
  File "C:\Python\Python38\lib\site-packages\quo\output\defaults.py", line 59, in create_output
    from .console_emulator import ConEmu
  File "C:\Python\Python38\lib\site-packages\quo\output\console_emulator.py", line 8, in <module>
    from .win32 import Win32Output
  File "C:\Python\Python38\lib\site-packages\quo\output\win32.py", line 16, in <module>
    from quo.utils import get_cwidth
ImportError: cannot import name 'get_cwidth' from 'quo.utils' (C:\Python\Python38\lib\site-packages\quo\utils\__init__.py)

To Reproduce
Steps to reproduce the behavior:

  1. Try to execute example
import quo

completer = quo.completion.WordCompleter(['USA', 'UK', 'Canada', 'Kenya'])
session = quo.Prompt(completer=completer)
session.prompt('Which country are you from?: ')
  1. See error

Expected behavior
Not throw an error.

Desktop (please complete the following information):

  • OS: Windows 10 x64
  • Python version: 3.8
  • Quo version: 2021.07

Overline text

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
Adding and overline

[BUG]

You may find a solution to your problem in the docs or issues.

Describe the bug
:meth:quo.console.Console.size object not Callable

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Broken placeholder()

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.