File tree 4 files changed +32
-26
lines changed
4 files changed +32
-26
lines changed Original file line number Diff line number Diff line change 12
12
#
13
13
import os
14
14
import sys
15
- sys .path .insert (0 , os .path .abspath ('..' ))
15
+
16
+ sys .path .insert (0 , os .path .abspath (".." ))
16
17
from jupyter_ui_poll import __version__
17
18
18
19
84
85
"logo_only" : True ,
85
86
}
86
87
87
- #html_logo = '_static/logo.svg'
88
- html_last_updated_fmt = ' %b %d, %Y'
88
+ # html_logo = '_static/logo.svg'
89
+ html_last_updated_fmt = " %b %d, %Y"
89
90
html_show_sphinx = False
90
91
91
92
Original file line number Diff line number Diff line change 3
3
import time
4
4
from collections import abc
5
5
from functools import singledispatch
6
- from inspect import iscoroutinefunction , isawaitable
6
+ from inspect import isawaitable , iscoroutinefunction
7
7
from typing import (
8
8
Any ,
9
9
AsyncIterable ,
16
16
Optional ,
17
17
Tuple ,
18
18
TypeVar ,
19
- Union ,
20
19
)
21
20
22
21
import zmq
@@ -153,7 +152,9 @@ def get() -> "KernelWrapper":
153
152
154
153
class IteratorWrapperAsync (abc .AsyncIterable , Generic [T ]):
155
154
def __init__ (
156
- self , its : AsyncIterable [T ], n : int = 1 ,
155
+ self ,
156
+ its : AsyncIterable [T ],
157
+ n : int = 1 ,
157
158
):
158
159
self ._its = its
159
160
self ._n = n
@@ -172,7 +173,9 @@ async def _loop(
172
173
173
174
class IteratorWrapper (abc .Iterable , Generic [T ]):
174
175
def __init__ (
175
- self , its : Iterable [T ], n : int = 1 ,
176
+ self ,
177
+ its : Iterable [T ],
178
+ n : int = 1 ,
176
179
):
177
180
self ._its = its
178
181
self ._n = n
Original file line number Diff line number Diff line change 23
23
" from ipywidgets import HTML\n " ,
24
24
" from ui import blocking_ui\n " ,
25
25
" \n " ,
26
- " color, mode = blocking_ui(default=' beige' , timeout=10)"
26
+ " color, mode = blocking_ui(default=\" beige\" , timeout=10)"
27
27
]
28
28
},
29
29
{
32
32
"metadata" : {},
33
33
"outputs" : [],
34
34
"source" : [
35
- " if mode == ' user' :\n " ,
35
+ " if mode == \" user\" :\n " ,
36
36
" print(f\" So you picked '{color}'\" )\n " ,
37
37
" else:\n " ,
38
- " print(' Try to click faster next time' )\n " ,
38
+ " print(\" Try to click faster next time\" )\n " ,
39
39
" \n " ,
40
- " HTML(f'''\n " ,
40
+ " HTML(\n " ,
41
+ " f\"\"\"\n " ,
41
42
" <div style=\" width:100px;\n " ,
42
43
" height:100px;\n " ,
43
44
" background:{color};\n " ,
44
45
" padding:10px;\n " ,
45
46
" border-color:black;\n " ,
46
- " border-style:solid\" ><b>{color}</b></div>''')"
47
+ " border-style:solid\" ><b>{color}</b></div>\"\"\"\n " ,
48
+ " )"
47
49
]
48
50
},
49
51
{
Original file line number Diff line number Diff line change @@ -55,27 +55,27 @@ def mk_btn(color):
55
55
56
56
57
57
def blocking_ui (default = "beige" , timeout = 10 ):
58
- """ Displays a UI then blocks until user makes a choice or timeout happens.
58
+ """Displays a UI then blocks until user makes a choice or timeout happens.
59
59
60
- Returns
61
- =======
62
- (color, 'user') if user selects a color in time
63
- (default, 'timeout') in case of a timeout
60
+ Returns
61
+ =======
62
+ (color, 'user') if user selects a color in time
63
+ (default, 'timeout') in case of a timeout
64
64
"""
65
65
state = make_sample_ui ()
66
66
67
67
def poll_cbk ():
68
- """ This function is called periodically.
68
+ """This function is called periodically.
69
69
70
- - Check for user input
71
- - Check for timeout
72
- - Update timeout progress bar
70
+ - Check for user input
71
+ - Check for timeout
72
+ - Update timeout progress bar
73
73
74
- Returns
75
- -------
76
- (color: str, 'user') -- when user selection detected
77
- (default: str, 'timeout') -- when no user selection for too long
78
- None -- in all other cases
74
+ Returns
75
+ -------
76
+ (color: str, 'user') -- when user selection detected
77
+ (default: str, 'timeout') -- when no user selection for too long
78
+ None -- in all other cases
79
79
"""
80
80
if state .color is not None : # User selected some color
81
81
return state .color , "user"
You can’t perform that action at this time.
0 commit comments