panel.io package#
Submodules#
- panel.io.admin module
- panel.io.application module
- panel.io.browser module
- panel.io.cache module
- panel.io.callbacks module
- panel.io.compile module
- panel.io.convert module
- panel.io.datamodel module
- panel.io.django module
- panel.io.document module
- panel.io.embed module
- panel.io.fastapi module
- panel.io.handlers module
- panel.io.ipywidget module
- panel.io.jupyter_executor module
- panel.io.jupyter_server_extension module
- panel.io.liveness module
- panel.io.loading module
- panel.io.location module
- panel.io.logging module
- panel.io.mime_render module
- panel.io.model module
- panel.io.notebook module
- panel.io.notifications module
- panel.io.profile module
- panel.io.pyodide module
- panel.io.reload module
- panel.io.resources module
- panel.io.rest module
- panel.io.save module
- panel.io.server module
- panel.io.session module
- panel.io.state module
- panel.io.threads module
Module contents#
The io module contains utilities for loading JS components, embedding model state, and rendering panel objects.
- class panel.io.PeriodicCallback(*, callback, count, counter, log, period, running, timeout, name)[source]#
Bases:
Parameterized
Periodic encapsulates a periodic callback which will run both in tornado based notebook environments and on bokeh server. By default the callback will run until the stop method is called, but count and timeout values can be set to limit the number of executions or the maximum length of time for which the callback will run. The callback may also be started and stopped by setting the running parameter to True or False respectively.
Methods
Parameter Definitions
callback = Callable(allow_None=True, label='Callback')
The callback to execute periodically.
counter = Integer(default=0, inclusive_bounds=(True, True), label='Counter')
Counts the number of executions.
count = Integer(allow_None=True, inclusive_bounds=(True, True), label='Count')
Number of times the callback will be executed, by default this is unlimited.
log = Boolean(default=True, label='Log')
Whether the periodic callback should log its actions.
period = Integer(default=500, inclusive_bounds=(True, True), label='Period')
Period in milliseconds at which the callback is executed.
timeout = Integer(allow_None=True, inclusive_bounds=(True, True), label='Timeout')
Timeout in milliseconds from the start time at which the callback expires.
running = Boolean(default=False, label='Running')
Toggles whether the periodic callback is currently running.
- class panel.io.Resources(*args, absolute=False, notebook=False, **kwargs)[source]#
Bases:
Resources
- panel.io.hold(doc: Document | None = None, policy: HoldPolicyType = 'combine', comm: Comm | None = None)[source]#
Context manager that holds events on a particular Document allowing them all to be collected and dispatched when the context manager exits. This allows multiple events on the same object to be combined if the policy is set to ‘combine’.
- Parameters:
- doc: Document
The Bokeh Document to hold events on.
- policy: HoldPolicyType
One of ‘combine’, ‘collect’ or None determining whether events setting the same property are combined or accumulated to be dispatched when the context manager exits.
- comm: Comm
The Comm to dispatch events on when the context manager exits.
- panel.io.immediate_dispatch(doc: Document | None = None)[source]#
Context manager to trigger immediate dispatch of events triggered inside the execution context even when Document events are currently on hold.
- Parameters:
- doc: Document
The document to dispatch events on (if None then state.curdoc is used).
- panel.io.ipywidget(obj: Any, doc=None, **kwargs: Any)[source]#
Returns an ipywidget model which renders the Panel object.
Requires jupyter_bokeh to be installed.
- Parameters:
- obj: object
Any Panel object or object which can be rendered with Panel
- doc: bokeh.Document
Bokeh document the bokeh model will be attached to.
- **kwargs: dict
Keyword arguments passed to the pn.panel utility function
- Returns:
- Returns an ipywidget model which renders the Panel object.
- panel.io.profile(name: str, engine: ProfilingEngine = 'pyinstrument') Callable[[Callable[_P, _R]], Callable[_P, _R]] [source]#
A decorator which may be added to any function to record profiling output.
- Parameters:
- name: str
A unique name for the profiling session.
- engine: str
The profiling engine, e.g. ‘pyinstrument’, ‘snakeviz’ or ‘memray’
- panel.io.push(doc: Document, comm: Comm, binary: bool = True, msg: Message | None = None) None [source]#
Pushes events stored on the document across the provided comm.
- panel.io.push_notebook(*objs: Viewable) None [source]#
A utility for pushing updates to the frontend given a Panel object. This is required when modifying any Bokeh object directly in a notebook session.
- Parameters:
- objs: panel.viewable.Viewable
- panel.io.serve(panels: TViewableFuncOrPath | dict[str, TViewableFuncOrPath], port: int = 0, address: str | None = None, websocket_origin: str | list[str] | None = None, loop: IOLoop | None = None, show: bool = True, start: bool = True, title: str | None = None, verbose: bool = True, location: bool = True, threaded: bool = False, admin: bool = False, **kwargs) StoppableThread | Server [source]#
Allows serving one or more panel objects on a single server. The panels argument should be either a Panel object or a function returning a Panel object or a dictionary of these two. If a dictionary is supplied the keys represent the slugs at which each app is served, e.g. serve({‘app’: panel1, ‘app2’: panel2}) will serve apps at /app and /app2 on the server.
Reference: https://panel.holoviz.org/user_guide/Server_Configuration.html#serving-multiple-apps
- Parameters:
- panels: Viewable, function or {str: Viewable or function}
A Panel object, a function returning a Panel object or a dictionary mapping from the URL slug to either.
- port: int (optional, default=0)
Allows specifying a specific port
- addressstr
The address the server should listen on for HTTP requests.
- websocket_origin: str or list(str) (optional)
A list of hosts that can connect to the websocket.
This is typically required when embedding a server app in an external web site.
If None, “localhost” is used.
- looptornado.ioloop.IOLoop (optional, default=IOLoop.current())
The tornado IOLoop to run the Server on
- showboolean (optional, default=True)
Whether to open the server in a new browser tab on start
- startboolean(optional, default=True)
Whether to start the Server
- title: str or {str: str} (optional, default=None)
An HTML title for the application or a dictionary mapping from the URL slug to a customized title
- verbose: boolean (optional, default=True)
Whether to print the address and port
- locationboolean or panel.io.location.Location
Whether to create a Location component to observe and set the URL location.
- threaded: boolean (default=False)
Whether to start the server on a new Thread
- admin: boolean (default=False)
Whether to enable the admin panel
- kwargs: dict
Additional keyword arguments to pass to Server instance
- panel.io.unlocked(policy: HoldPolicyType = 'combine') Iterator [source]#
Context manager which unlocks a Document and dispatches ModelChangedEvents triggered in the context body to all sockets on current sessions.
- Parameters:
- policy: Literal[‘combine’ | ‘collect’]
One of ‘combine’ or ‘collect’ determining whether events setting the same property are combined or accumulated to be dispatched when the context manager exits.