Skip to content

How to get proper object oriented approach in NiceGUI #481

Closed Answered by TomaszSzyborski
TomaszSzyborski asked this question in Q&A
Discussion options

You must be logged in to vote

Ok, got it, I think I'll create a PR for that in examples

import asyncio
import httpx

from nicegui import events, ui
from nicegui.page import page
from typing import Optional

class Search:
    def __init__(self, results):
        self.results = results
        self.search_field = ui.input(on_change=self.search) \
            .props('autofocus outlined rounded item-aligned input-class="ml-3"') \
            .classes('w-96 self-center mt-24 transition-all')
        self.api = httpx.AsyncClient()
        self.running_query: Optional[asyncio.Task] = None

    async def search(self, e: events.ValueChangeEventArguments) -> None:
        '''Search for cocktails as you type.'''
        if self.r…

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
3 replies
@frankhuurman
Comment options

@falkoschindler
Comment options

@frankhuurman
Comment options

Answer selected by rodja
Comment options

You must be logged in to vote
3 replies
@TomaszSzyborski
Comment options

@jeremy886
Comment options

@rodja
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants