support async functions for table
- https://github.com/louisnw01/lightweight-charts-python/issues/296
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import asyncio
|
||||
import random
|
||||
from typing import Union
|
||||
|
||||
@ -69,10 +70,19 @@ class Table(Pane, dict):
|
||||
self._formatters = {}
|
||||
self.headings = headings
|
||||
self.is_shown = True
|
||||
def wrapper(rId, cId=None):
|
||||
if return_clicked_cells:
|
||||
self.win.handlers[self.id] = lambda rId, cId: func(self[rId], cId)
|
||||
func(self[rId], cId)
|
||||
else:
|
||||
self.win.handlers[self.id] = lambda rId: func(self[rId])
|
||||
func(self[rId])
|
||||
|
||||
async def async_wrapper(rId, cId=None):
|
||||
if return_clicked_cells:
|
||||
await func(self[rId], cId)
|
||||
else:
|
||||
await func(self[rId])
|
||||
|
||||
self.win.handlers[self.id] = async_wrapper if asyncio.iscoroutinefunction(func) else wrapper
|
||||
self.return_clicked_cells = return_clicked_cells
|
||||
|
||||
headings = list(headings)
|
||||
|
||||
Reference in New Issue
Block a user