Skip to content

Commit

Permalink
Merge pull request #85 from scalabli/_quo
Browse files Browse the repository at this point in the history
#SpinningWheel fix
  • Loading branch information
quantum-quirks committed May 7, 2022
2 parents 8187788 + 364acda commit 3462df4
Show file tree
Hide file tree
Showing 10 changed files with 210 additions and 23 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ Try this:
```python
from quo import echo

echo(f"Hello, World!", fg="red", italic=True, bold=True))
echo("Hello, World!", fg="red", italic=True, bold=True)
```
![Hello World](https://github.com/scalabli/quo/raw/master/pics/print.png)

**Example 2**
```python
from quo import echo

echo(f"Quo is ", nl=False)
echo(f"scalable", bg="red", fg="black")
echo("Quo is ", nl=False)
echo("scalable", bg="red", fg="black")
```
![Scalable](https://github.com/scalabli/quo/raw/master/pics/scalable.png)

Expand Down
12 changes: 12 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ Changelog

.. image:: https://media.giphy.com/media/12oufCB0MyZ1Go/giphy.gif

``Version 2022.5.1``
---------------------

Released on 2022-05-07

**Fixed**
^^^^^^^^^^^
- Fixed :class:`SpinningWheel` attribute error.




``Version 2022.5``
--------------------

Expand Down
31 changes: 31 additions & 0 deletions examples/dialogs/ind.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env python
"""
Example of an input box dialog.
"""
import time
import multiprocessing
from quo import print
from quo.dialog import InputBox

#start_time = time.time()

def main():
result = InputBox(
title="PromptBox shenanigans",
text="What Country are you from?:"
)
def ok():
pass
# return print(f"{result}")

def mult(i):
with multiprocessing.Pool() as pool:
pool.map(ok, i)
#int(f"Result = {result}")
if __name__ == "__main__":
n = None
start_time = time.time()
main()
duration = time.time() - start_time
print(f"Duration {duration}")

22 changes: 12 additions & 10 deletions examples/full-screen/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
A simple example of a calculator program.
This could be used as inspiration for a REPL.
"""
import cProfile
from quo import container
from quo.document import Document
from quo.keys import bind
Expand All @@ -19,11 +20,11 @@ def main():
# The layout.
search_field = SearchToolbar() # For reverse search.

output_field = TextArea(f'{help_text}', style="bg:blue fg:yellow bold")
output_field = TextArea(f"{help_text}", style="bg:blue fg:yellow bold")
input_field = TextArea(
height=2,
prompt=">>",
style="bg:gray fg:green", #class:input-field",
style="bg:gray fg:green", # class:input-field",
multiline=False,
wrap_lines=False,
search_field=search_field,
Expand Down Expand Up @@ -62,14 +63,15 @@ def accept(buff):
input_field.accept_handler = accept

# The key bindings.
@bind.add("ctrl-c")
@bind.add("ctrl-q")
def _(event):
"Pressing Ctrl-Q or Ctrl-C will exit the user interface."
event.app.exit()

container(content, bind=True, focused_element=input_field, full_screen=True, mouse_support=True)
# "Pressing Ctrl-Q or Ctrl-C will exit the user interface."
container(
content,
bind=True,
focused_element=input_field,
full_screen=True,
mouse_support=True,
)


if __name__ == "__main__":
main()
cProfile.run("main()")
8 changes: 0 additions & 8 deletions examples/full-screen/simple-demos/autocompletion.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,3 @@
# The `Application`

container(content, bind=True, full_screen=True)
#pplication = quo.console.Console(layout=quo.layout.Layout(body), bind=kb, full_screen=True)


#def run():
# application.run()

#if __name__ == "__main__":
# run()
63 changes: 63 additions & 0 deletions examples/print-text/asm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env python
"""
Example of printing colored text to the output.
"""
import time
import asyncio
import concurrent.futures
import multiprocessing
from quo import print
from quo.text import FormattedText
from quo.style import Style

async def main():
style = Style.add(
{
"hello": "#ff0066",
"world": "#44ff44 italic",
}
)

# Print using a a list of text fragments.
text_fragments = FormattedText(
[
("class:hello", "Hello "),
("class:world", "World"),
("", "\n"),
]
)
async def ok(text_fragments, style):
async with text_framents as txt:
print(txt, style=style)

async def oks(dits):
tasks = []
task = asyncio.ensure_future(ok(text_fragments,style))
tasks.append(task)
await asyncio.gather(*tasks, return_exceptions=True)

def asyc_tasks(dits):
asyncio.get_event_loop().run_until_complete(ok(dits))



# with multiprocessing.Pool() as pool:
# pool.map(ok, dits)
#print(text_fragments, style=style)

# Print using an HTML object.
print("<hello>hello</hello> <world>world</world>\n", style=style)

# Print using an HTML object with inline styling.
print('<style fg="#ff0066">hello</style> '
'<style fg="#44ff44"><i>world</i></style>\n'
)

if __name__ == "__main__":
start = time.time()
with concurrent.futures.ProcessPoolExecutor(max_workers=5) as ex:
futures = [ex.submit(asyc_tasks)]
for future in concurrent.futures.as_completed(futures):
pass
duration = time.time() - start
print(f"Duration {duration}")
47 changes: 47 additions & 0 deletions examples/print-text/multi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env python
"""
Example of printing colored text to the output.
"""
import time
import multiprocessing
from quo import print
from quo.text import FormattedText
from quo.style import Style

def main():
style = Style.add(
{
"hello": "#ff0066",
"world": "#44ff44 italic",
}
)

# Print using a a list of text fragments.
text_fragments = FormattedText(
[
("class:hello", "Hello "),
("class:world", "World"),
("", "\n"),
]
)
def ok(text_fragments, style):
return print(text_fragments, style=style)

def oks(dits):
with multiprocessing.Pool() as pool:
pool.map(ok, dits)
#print(text_fragments, style=style)

# Print using an HTML object.
print("<hello>hello</hello> <world>world</world>\n", style=style)

# Print using an HTML object with inline styling.
print('<style fg="#ff0066">hello</style> '
'<style fg="#44ff44"><i>world</i></style>\n'
)

if __name__ == "__main__":
start = time.time()
main()
duration = time.time() - start
print(f"Duration {duration}")
40 changes: 40 additions & 0 deletions examples/print-text/timeit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env python
"""
Example of printing colored text to the output.
"""
import time
from quo import print
from quo.text import FormattedText
from quo.style import Style

def main():
style = Style.add(
{
"hello": "#ff0066",
"world": "#44ff44 italic",
}
)

# Print using a a list of text fragments.
text_fragments = FormattedText(
[
("class:hello", "Hello "),
("class:world", "World"),
("", "\n"),
]
)
print(text_fragments, style=style)

# Print using an HTML object.
print("<hello>hello</hello> <world>world</world>\n", style=style)

# Print using an HTML object with inline styling.
print('<style fg="#ff0066">hello</style> '
'<style fg="#44ff44"><i>world</i></style>\n'
)

if __name__ == "__main__":
start = time.time()
main()
duration = time.time() - start
print(f"Duration {duration}")
2 changes: 1 addition & 1 deletion src/quo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,4 @@ def print(*values, style=None, sep=" ", end="\n"):

from quo.shortcuts.utils import container

__version__ = "2022.5"
__version__ = "2022.5.1"
2 changes: 1 addition & 1 deletion src/quo/progress/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ class SpinningWheel(Formatter):
from quo._spinners import SPINNERS

characters = SPINNERS.dots3
win_chars = r"/-\|"

def format(
self,
Expand All @@ -352,7 +353,6 @@ def format(
from quo.accordance import WIN

if WIN:
win_chars = r"/-\|"
index = int(time.time() * 7) % len(self.win_chars)
return Te("<spinning-wheel><b>{0}</b></spinning-wheel>").format(self.win_chars[index])
else:
Expand Down

0 comments on commit 3462df4

Please sign in to comment.