Skip to content

Commit ef4580a

Browse files
committed
fix: async/await for python 3.12
1 parent 8af331c commit ef4580a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/ctui/dialogs.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,14 @@ def __pt_container__(self):
187187
return self.dialog
188188

189189

190-
def show_dialog(dialog):
190+
async def show_dialog(dialog):
191191
"Coroutine."
192192
app = get_app()
193193
float_ = Float(content=dialog)
194194
app.layout.container.floats.insert(0, float_)
195195
focused_before = app.layout.current_window
196196
app.layout.focus(dialog)
197-
result = yield from dialog.future
197+
result = await dialog.future
198198
app.layout.focus(focused_before)
199199

200200
if float_ in app.layout.container.floats:
@@ -223,9 +223,9 @@ def yes_no_dialog(
223223
Execute a passed function.
224224
"""
225225

226-
def coroutine():
226+
async def coroutine():
227227
dialog = YesNoDialog(title=title, text=text, yes_text=yes_text, no_text=no_text)
228-
result = yield from show_dialog(dialog)
228+
result = await show_dialog(dialog)
229229
if result == True:
230230
yes_func()
231231
else:
@@ -255,11 +255,11 @@ def input_dialog(
255255
"""
256256
output_text = ""
257257

258-
def coroutine():
258+
async def coroutine():
259259
global output_text
260260
open_dialog = TextInputDialog(title, text, completer)
261261

262-
output_text = yield from show_dialog(open_dialog)
262+
output_text = await show_dialog(open_dialog)
263263

264264
ensure_future(coroutine())
265265
return output_text
@@ -278,7 +278,7 @@ def message_dialog(
278278
Display a simple message box and wait until the user presses enter.
279279
"""
280280

281-
def coroutine():
281+
async def coroutine():
282282
dialog = MessageDialog(
283283
title=title,
284284
text=text,
@@ -287,7 +287,7 @@ def coroutine():
287287
wrap_lines=wrap_lines,
288288
scrollbar=scrollbar,
289289
)
290-
yield from show_dialog(dialog)
290+
await show_dialog(dialog)
291291

292292
ensure_future(coroutine())
293293

0 commit comments

Comments
 (0)