Advice on working with ListView and ListItem #4322
Answered
by
davep
MuongKimhong
asked this question in
Q&A
-
What I'm doing: Currently, I'm doing it this way and it's a bit unresponsive when response data has length of 20 or 30. def on_input_changed(self, event: Input.Changed) -> None:
self.search(event.value)
def search(self, search_text: str) -> None:
data_list_view = self.app.query_one("#data-list-view")
data_list_view.clear()
if search_text.strip() != "":
res = requests.get(...) # make requests
list_items = [CustomListItem(data["key_one"], data["key_two"]) for data in res["data"]]
data_list_view.extend(list_items) I tried https://textual.textualize.io/guide/workers/#work-decorator, but i dont see any changes in performance. |
Beta Was this translation helpful? Give feedback.
Answered by
davep
Mar 21, 2024
Replies: 1 comment 4 replies
-
Notce that the example uses an async API like |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@MuongKimhong You're calling
call_from_thread
with the result of callingListView.extend
, what you should be doing is passing a reference to the function you want to call. For example: