Skip to content

Commit

Permalink
Merge branch 'main' of github.com:zauberzeug/nicegui
Browse files Browse the repository at this point in the history
  • Loading branch information
rodja committed Oct 25, 2022
2 parents dba688f + 317e73d commit 5817406
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions api_docs_and_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ def page(word: str, count: int):
This contains the websocket of the client.
'''
with example(yield_page_ready):
import asyncio
from typing import Generator

from nicegui.events import PageEvent
Expand Down
14 changes: 10 additions & 4 deletions nicegui/events.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import traceback
from dataclasses import dataclass
from inspect import signature
from typing import Any, Callable, List, Optional
from typing import TYPE_CHECKING, Any, Callable, List, Optional

from starlette.websockets import WebSocket

from . import globals
from .elements.element import Element
from .helpers import is_coroutine
from .lifecycle import on_startup
from .page import PageEvent
from .task_logger import create_task

if TYPE_CHECKING:
from .elements.element import Element


@dataclass
class EventArguments:
sender: Element
sender: 'Element'
socket: Optional[WebSocket]


Expand Down Expand Up @@ -226,6 +227,11 @@ class KeyEventArguments(EventArguments):
modifiers: KeyboardModifiers


@dataclass
class PageEvent:
socket: WebSocket


def handle_event(handler: Optional[Callable], arguments: EventArguments) -> Optional[bool]:
try:
if handler is None:
Expand Down
7 changes: 1 addition & 6 deletions nicegui/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import traceback
import types
import uuid
from dataclasses import dataclass
from functools import wraps
from typing import Callable, Dict, Generator, List, Optional

Expand All @@ -19,16 +18,12 @@
from starlette.websockets import WebSocket

from . import globals
from .events import PageEvent
from .helpers import is_coroutine
from .page_builder import PageBuilder
from .routes import add_route, convert_arguments


@dataclass
class PageEvent:
socket: WebSocket


class Page(jp.QuasarPage):

def __init__(self,
Expand Down
1 change: 0 additions & 1 deletion tests/test_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from uuid import uuid4

import justpy.htmlcomponents
import pytest
from nicegui import task_logger, ui
from nicegui.events import PageEvent
from starlette.requests import Request
Expand Down

0 comments on commit 5817406

Please sign in to comment.