Skip to content

Commit 3462df4

Browse files
Merge pull request #85 from scalabli/_quo
#SpinningWheel fix
2 parents 8187788 + 364acda commit 3462df4

File tree

10 files changed

+210
-23
lines changed

10 files changed

+210
-23
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,16 @@ Try this:
6464
```python
6565
from quo import echo
6666

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

7171
**Example 2**
7272
```python
7373
from quo import echo
7474

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

docs/changes.rst

+12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ Changelog
77

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

10+
``Version 2022.5.1``
11+
---------------------
12+
13+
Released on 2022-05-07
14+
15+
**Fixed**
16+
^^^^^^^^^^^
17+
- Fixed :class:`SpinningWheel` attribute error.
18+
19+
20+
21+
1022
``Version 2022.5``
1123
--------------------
1224

examples/dialogs/ind.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python
2+
"""
3+
Example of an input box dialog.
4+
"""
5+
import time
6+
import multiprocessing
7+
from quo import print
8+
from quo.dialog import InputBox
9+
10+
#start_time = time.time()
11+
12+
def main():
13+
result = InputBox(
14+
title="PromptBox shenanigans",
15+
text="What Country are you from?:"
16+
)
17+
def ok():
18+
pass
19+
# return print(f"{result}")
20+
21+
def mult(i):
22+
with multiprocessing.Pool() as pool:
23+
pool.map(ok, i)
24+
#int(f"Result = {result}")
25+
if __name__ == "__main__":
26+
n = None
27+
start_time = time.time()
28+
main()
29+
duration = time.time() - start_time
30+
print(f"Duration {duration}")
31+

examples/full-screen/calculator.py

+12-10
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
A simple example of a calculator program.
44
This could be used as inspiration for a REPL.
55
"""
6+
import cProfile
67
from quo import container
78
from quo.document import Document
89
from quo.keys import bind
@@ -19,11 +20,11 @@ def main():
1920
# The layout.
2021
search_field = SearchToolbar() # For reverse search.
2122

22-
output_field = TextArea(f'{help_text}', style="bg:blue fg:yellow bold")
23+
output_field = TextArea(f"{help_text}", style="bg:blue fg:yellow bold")
2324
input_field = TextArea(
2425
height=2,
2526
prompt=">>",
26-
style="bg:gray fg:green", #class:input-field",
27+
style="bg:gray fg:green", # class:input-field",
2728
multiline=False,
2829
wrap_lines=False,
2930
search_field=search_field,
@@ -62,14 +63,15 @@ def accept(buff):
6263
input_field.accept_handler = accept
6364

6465
# The key bindings.
65-
@bind.add("ctrl-c")
66-
@bind.add("ctrl-q")
67-
def _(event):
68-
"Pressing Ctrl-Q or Ctrl-C will exit the user interface."
69-
event.app.exit()
70-
71-
container(content, bind=True, focused_element=input_field, full_screen=True, mouse_support=True)
66+
# "Pressing Ctrl-Q or Ctrl-C will exit the user interface."
67+
container(
68+
content,
69+
bind=True,
70+
focused_element=input_field,
71+
full_screen=True,
72+
mouse_support=True,
73+
)
7274

7375

7476
if __name__ == "__main__":
75-
main()
77+
cProfile.run("main()")

examples/full-screen/simple-demos/autocompletion.py

-8
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,3 @@
7272
# The `Application`
7373

7474
container(content, bind=True, full_screen=True)
75-
#pplication = quo.console.Console(layout=quo.layout.Layout(body), bind=kb, full_screen=True)
76-
77-
78-
#def run():
79-
# application.run()
80-
81-
#if __name__ == "__main__":
82-
# run()

examples/print-text/asm.py

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env python
2+
"""
3+
Example of printing colored text to the output.
4+
"""
5+
import time
6+
import asyncio
7+
import concurrent.futures
8+
import multiprocessing
9+
from quo import print
10+
from quo.text import FormattedText
11+
from quo.style import Style
12+
13+
async def main():
14+
style = Style.add(
15+
{
16+
"hello": "#ff0066",
17+
"world": "#44ff44 italic",
18+
}
19+
)
20+
21+
# Print using a a list of text fragments.
22+
text_fragments = FormattedText(
23+
[
24+
("class:hello", "Hello "),
25+
("class:world", "World"),
26+
("", "\n"),
27+
]
28+
)
29+
async def ok(text_fragments, style):
30+
async with text_framents as txt:
31+
print(txt, style=style)
32+
33+
async def oks(dits):
34+
tasks = []
35+
task = asyncio.ensure_future(ok(text_fragments,style))
36+
tasks.append(task)
37+
await asyncio.gather(*tasks, return_exceptions=True)
38+
39+
def asyc_tasks(dits):
40+
asyncio.get_event_loop().run_until_complete(ok(dits))
41+
42+
43+
44+
# with multiprocessing.Pool() as pool:
45+
# pool.map(ok, dits)
46+
#print(text_fragments, style=style)
47+
48+
# Print using an HTML object.
49+
print("<hello>hello</hello> <world>world</world>\n", style=style)
50+
51+
# Print using an HTML object with inline styling.
52+
print('<style fg="#ff0066">hello</style> '
53+
'<style fg="#44ff44"><i>world</i></style>\n'
54+
)
55+
56+
if __name__ == "__main__":
57+
start = time.time()
58+
with concurrent.futures.ProcessPoolExecutor(max_workers=5) as ex:
59+
futures = [ex.submit(asyc_tasks)]
60+
for future in concurrent.futures.as_completed(futures):
61+
pass
62+
duration = time.time() - start
63+
print(f"Duration {duration}")

examples/print-text/multi.py

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env python
2+
"""
3+
Example of printing colored text to the output.
4+
"""
5+
import time
6+
import multiprocessing
7+
from quo import print
8+
from quo.text import FormattedText
9+
from quo.style import Style
10+
11+
def main():
12+
style = Style.add(
13+
{
14+
"hello": "#ff0066",
15+
"world": "#44ff44 italic",
16+
}
17+
)
18+
19+
# Print using a a list of text fragments.
20+
text_fragments = FormattedText(
21+
[
22+
("class:hello", "Hello "),
23+
("class:world", "World"),
24+
("", "\n"),
25+
]
26+
)
27+
def ok(text_fragments, style):
28+
return print(text_fragments, style=style)
29+
30+
def oks(dits):
31+
with multiprocessing.Pool() as pool:
32+
pool.map(ok, dits)
33+
#print(text_fragments, style=style)
34+
35+
# Print using an HTML object.
36+
print("<hello>hello</hello> <world>world</world>\n", style=style)
37+
38+
# Print using an HTML object with inline styling.
39+
print('<style fg="#ff0066">hello</style> '
40+
'<style fg="#44ff44"><i>world</i></style>\n'
41+
)
42+
43+
if __name__ == "__main__":
44+
start = time.time()
45+
main()
46+
duration = time.time() - start
47+
print(f"Duration {duration}")

examples/print-text/timeit.py

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env python
2+
"""
3+
Example of printing colored text to the output.
4+
"""
5+
import time
6+
from quo import print
7+
from quo.text import FormattedText
8+
from quo.style import Style
9+
10+
def main():
11+
style = Style.add(
12+
{
13+
"hello": "#ff0066",
14+
"world": "#44ff44 italic",
15+
}
16+
)
17+
18+
# Print using a a list of text fragments.
19+
text_fragments = FormattedText(
20+
[
21+
("class:hello", "Hello "),
22+
("class:world", "World"),
23+
("", "\n"),
24+
]
25+
)
26+
print(text_fragments, style=style)
27+
28+
# Print using an HTML object.
29+
print("<hello>hello</hello> <world>world</world>\n", style=style)
30+
31+
# Print using an HTML object with inline styling.
32+
print('<style fg="#ff0066">hello</style> '
33+
'<style fg="#44ff44"><i>world</i></style>\n'
34+
)
35+
36+
if __name__ == "__main__":
37+
start = time.time()
38+
main()
39+
duration = time.time() - start
40+
print(f"Duration {duration}")

src/quo/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,4 @@ def print(*values, style=None, sep=" ", end="\n"):
112112

113113
from quo.shortcuts.utils import container
114114

115-
__version__ = "2022.5"
115+
__version__ = "2022.5.1"

src/quo/progress/formatters.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ class SpinningWheel(Formatter):
342342
from quo._spinners import SPINNERS
343343

344344
characters = SPINNERS.dots3
345+
win_chars = r"/-\|"
345346

346347
def format(
347348
self,
@@ -352,7 +353,6 @@ def format(
352353
from quo.accordance import WIN
353354

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

0 commit comments

Comments
 (0)