Skip to content

Commit

Permalink
🚀🚀🎭
Browse files Browse the repository at this point in the history
  • Loading branch information
quantum-quirks committed Apr 1, 2022
1 parent 35f8505 commit 582a29e
Show file tree
Hide file tree
Showing 76 changed files with 1,019 additions and 643 deletions.
7 changes: 5 additions & 2 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ Unreleased
**Added**
^^^^^^^^^^

- :meth:`quo.console.Console.pager`
- :param:`fmt` to :func:`quo.print`
- Added :meth:`quo.console.Console.pager`
- Added :param:`fmt` to :func:`quo.print`
- Added :param:`bg` to all dialog boxes.
- Added :param:`multiline` to :func:`quo.dialog.InputBox`
- Added `TextField` as an aliase to :class:`TextArea`

**Changed**
^^^^^^^^^^^^
Expand Down
7 changes: 4 additions & 3 deletions docs/dialogs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Dialogs
=======
Quo ships with a high level API for displaying `dialog boxes <https://en.m.wikipedia.org/wiki/Dialog_box>`_ to the user for informational purposes, or get input from the user.

All dialogs can be passed ``bg=False`` option to turn off the background. *Added on v2022.4*

*Deprecated :meth:`.run` on v2022.3.2*

``Message Box``
Expand Down Expand Up @@ -37,9 +39,8 @@ input box. It will return the user input as a string.
text='Please type your name:')
.. image:: ./images/inputbox.png


The ``hide=True`` option can be passed to the
:func:`~quo.dialog.InputBox` function to turn this into a password input box.
The ``multiline=True`` option can be passed turn this into a multiline Input box
The ``hide=True`` option can be passed to the :func:`~quo.dialog.InputBox` function to turn this into a password input box.


``Confirm Box``
Expand Down
5 changes: 2 additions & 3 deletions docs/filters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ from a function. For instance, the following condition will evaluate to ``True``

.. code:: python
from quo import Condition
from quo.console import get_app
from quo.filters import Condition
@Condition
def is_searching():
Expand Down Expand Up @@ -137,8 +137,7 @@ instance, and always returns a :class:`~quo.filters.Filter`.

.. code:: python
from quo import Condition
from quo.filters import to_filter, has_search, has_selection
from quo.filters import Condition, to_filter, has_search, has_selection
# In each of the following three examples, 'f' will be a `Filter`
# instance.
Expand Down
4 changes: 2 additions & 2 deletions docs/kb.rst
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ pass it to :class:`~quo.Condition` instance. (:ref:`Read more about filters <fil
.. code:: python
import datetime
from quo import Condition
from quo.filters import Condition
from quo.keys import bind
@Condition
Expand All @@ -214,7 +214,7 @@ Sometimes you want to enable or disable a whole set of key bindings according to

.. code:: python
from quo import Condition
from quo.filters import Condition
from quo.keys ConditionalKeyBindings
@Condition
Expand Down
10 changes: 5 additions & 5 deletions docs/prompt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,15 @@ exceed the given width. (The width of the prompt margin is defined by the prompt
When the ``hide=True`` flag in :func:`quo.prompt` or :class:`quo.prompt.Prompt` has been given, the input is hidden in :func:`quo.prompt` or replaced by asterisks (``*`` characters) in :class:`quo.prompt.Prompt`


``Using function quo.prompt()``
Using function quo.prompt()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code:: python
from quo import prompt
prompt("Enter password: ", hide=True)
``Using class `quo.prompt.Prompt()``
Using class `quo.prompt.Prompt()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code:: python
Expand Down Expand Up @@ -645,12 +645,12 @@ same time, but it is possible to switch between Emacs and Vi bindings at run
time.

In order to enable a key binding according to a certain condition, we have to
pass it a :class:`~quo.Condition` instance. (:ref:`Read more about filters <filters>`.)
pass it a :class:`~quo.filters.Condition` instance. (:ref:`Read more about filters <filters>`.)

.. code:: python
import datetime
from quo import Condition
from quo.filters import Condition
from quo.keys import bind
from quo.prompt import Prompt
Expand All @@ -672,7 +672,7 @@ Display asterisks instead of the actual characters with the addition of a Contro

.. code:: python
from quo import Condition
from quo.filters import Condition
from quo.keys import bind
from quo.prompt import Prompt
Expand Down
15 changes: 15 additions & 0 deletions examples/dialogs/1
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python
"""
Example of an input box dialog.
"""
from quo import print
from quo.dialog import InputBox

result = InputBox(
title="PromptBox shenanigans",
text="What Country are you from?:",
multiline=True,
bg=False)

print(f"Result = {result}")

5 changes: 3 additions & 2 deletions examples/dialogs/checkbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""
Example of a checkbox-list-based dialog.
"""
from quo import echo
#from quo import echo
from quo.dialog import CheckBox, MessageBox
from quo.text import Text
from quo.style import Style
Expand All @@ -26,6 +26,7 @@
("croissants", "20 Croissants"),
("daily", "The breakfast of the day"),
],
bg=False
)# style=style)

if results:
Expand All @@ -34,4 +35,4 @@
text="You selected: %s\nGreat choice sir !" % ",".join(results))

else:
MessageBox("*starves*")
MessageBox("*starves*", bg=False)
8 changes: 5 additions & 3 deletions examples/dialogs/choicebox.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Example of button dialog window.
"""

from quo import echo
#from quo import echo
from quo.dialog import ChoiceBox

result = ChoiceBox(
Expand All @@ -12,7 +12,9 @@
buttons= [
("Yes", True),
("No", False),
("Maybe...", None)]
("Maybe...", None)],
bg=False
)
if result == True:
echo(f"Result = {result}")
print("dd")
# echo(f"Result = {result}")
7 changes: 4 additions & 3 deletions examples/dialogs/confirm.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env python
from quo import echo
from quo import print
from quo.dialog import ConfirmBox
"""Example of a confirmation window"""

result = ConfirmBox(
title="Yes/No example",
text="Do you want to confirm?")
#echo(f"Result = {result}")
text="Do you want to confirm?",
bg=False)
print(f"Result = {result}")

11 changes: 11 additions & 0 deletions examples/dialogs/gg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def ff(percentage=0, log_text="ddd"):
tt = percentage

while tt is True:

print(log_text)


from quo.dialog import ProgressBox as d

d("ddddff", run_callback=ff)
9 changes: 5 additions & 4 deletions examples/dialogs/inputbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
"""
Example of an input box dialog.
"""
from quo import echo
from quo import print
from quo.dialog import InputBox
from quo.completion import WordCompleter

result = InputBox(
title="PromptBox shenanigans",
text="What Country are you from?:")
text="What Country are you from?:",
multiline=True,
bg=False)

echo(f"Result = {result}")
print(f"Result = {result}")

3 changes: 2 additions & 1 deletion examples/dialogs/messagebox.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@

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

5 changes: 3 additions & 2 deletions examples/dialogs/passwordbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
"""
Example of an password input dialog.
"""
from quo import echo
from quo import print
from quo.dialog import InputBox

result = InputBox(
title="Password dialog example",
text="Please type your password:",
bg=False,
hide=True)

echo(f"{result}")
print(f"{result}")

2 changes: 2 additions & 0 deletions examples/dialogs/progressbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""
import os
import time

from quo.dialog import ProgressBox

def worker(set_percentage, log_text):
Expand Down Expand Up @@ -35,6 +36,7 @@ def worker(set_percentage, log_text):
ProgressBox(
title="Progress box example",
text="As an examples, we walk through the filesystem and print all directories",
bg=True,
run_callback=worker
)

2 changes: 1 addition & 1 deletion examples/dialogs/styled_messagebox.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"dialog.body": "bg:white fg:black",
"dialog body.text-area": "fg:white bg:purple",
"dialog frame.label": "fg:blue bg:green",
# "dialog.shadow": "bg:yellow",
"dialog.shadow": "bg:yellow",
}
)

Expand Down
10 changes: 6 additions & 4 deletions examples/full-screen/buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ def button4():

def exit():
get_app().exit()

def dd():
content = Label("hello, world", style="fg:red bg:blue")
container(content, bind=True, full_screen=True)

# All the widgets for the UI.

Expand All @@ -37,6 +39,7 @@ def exit():
b2 = Button("Button 2", handler=button2)
b3 = Button("Button 3", handler=button3)
b4 = Button("Exit", handler=exit)
b6 = Button("has", handler=dd)
b5 = Button("kenya", handler=button4)
text_area = TextArea(scrollbar=True, focusable=True, style="brown")
lbl = Label("dkekkrkr")
Expand All @@ -50,7 +53,7 @@ def exit():
[
Label(text="Press `Tab` to move the focus."),
VSplit([
Box(body=HSplit([b1, b2, b3, b4, b5], padding=1),
Box(body=HSplit([b1, b2, b3, b4, b5, b6], padding=1),
padding=1,
style="bg:magenta"),
Box(body=Frame(text_area, title="eee"), padding=1, style="bg:blue fg:green")
Expand All @@ -63,8 +66,7 @@ def exit():


# Key bindings.
bind.add("l")(focus.last)
bind.add("tab")(focus.next)
bind.add("s-tab")(focus.previous)

container(content, bind=True, focused_element=b1, full_screen=True)
container(content, bind=True, focused_element=b3, full_screen=True)
10 changes: 5 additions & 5 deletions examples/full-screen/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
A simple example of a calculator program.
This could be used as inspiration for a REPL.
"""
from quo import container
from quo.console import Console
#from quo import container
from quo.console import container, Console
from quo.document import Document
from quo.keys import bind
from quo.layout import Window, HSplit, Layout
Expand Down Expand Up @@ -69,10 +69,10 @@ def _(event):
"Pressing Ctrl-Q or Ctrl-C will exit the user interface."
event.app.exit()

layout = Layout(container, focused_element=input_field)
Console(layout=layout).run()
# layout = Layout(container, focused_element=input_field)
# Console(layout=layout).run()

#container(content, bind=True, focused_element=input_field, full_screen=True, mouse_support=True)
container(content, bind=True, focused_element=input_field, full_screen=True, mouse_support=True)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion examples/full-screen/clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ def _(event):
event.app.exit()

#Console(layout=lay, bind=bind, refresh_interval=0.8).run()
container(content, full_screen=True)
container(content, bind=True, full_screen=True)
9 changes: 3 additions & 6 deletions examples/full-screen/hello-world.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
"""

from quo import container
from quo.keys import Bind
from quo.keys import bind
from quo.widget import Box, Frame, TextArea

# Layout for displaying hello world.
# (The frame creates the border, the box takes care of the margin/padding.)

bind = Bind()

# The Key bindings
@bind.add("ctrl-c")
def _(event):
Expand All @@ -25,9 +23,8 @@ def _(event):
TextArea("Hello world!\nPress control-c to quit.", width=40, height=10)
)
),
bind=bind,
full=True,
pre_run=True
bind=True,
full_screen=True
)


Loading

0 comments on commit 582a29e

Please sign in to comment.