omnipy.hub.ui
User-interface detection and Jupyter display setup helpers.
This module detects the active execution environment and provides the
user-facing setup_jupyter_ui() helper for enabling Omnipy's richer
notebook display integration.
| FUNCTION | DESCRIPTION |
|---|---|
detect_and_setup_user_interface |
Detect the active user interface and configure runtime display defaults. |
detect_dark_background |
Detect whether the active UI should be treated as using a dark background. |
detect_dark_terminal_background |
Detect whether the current terminal background is dark. |
detect_display_color_system |
Detect the display color system available for a specific UI type. |
detect_ui_type |
Detect the current Omnipy user-interface type from the execution environment. |
display_jupyter_setup_note |
Display setup guidance after Omnipy detects a Jupyter environment. |
get_terminal_prompt_height |
Return the prompt height for a terminal-oriented UI type. |
note_mime_bundle |
Build a MIME bundle for displaying a note in rich frontends. |
running_in_any_jupyter |
Return whether the current session is running in any Jupyter kernel. |
running_in_atty_terminal |
Return whether standard output is attached to an interactive terminal. |
running_in_ipython_pycharm |
Return whether the current session is running in PyCharm's IPython console. |
running_in_ipython_terminal |
Return whether the current session is running in an IPython terminal. |
running_in_jupyter_in_browser |
Return whether the current session is running in browser-hosted Jupyter. |
running_in_jupyter_in_pycharm |
Return whether the current session is running in PyCharm-hosted Jupyter. |
running_in_pycharm_console |
Return whether the current process is hosted by a PyCharm console. |
setup_displayhook_if_plain_terminal |
Install Omnipy's display hook for plain-terminal environments. |
setup_jupyter_ui |
Set up Omnipy's rich Jupyter display integration. |
detect_and_setup_user_interface
detect_and_setup_user_interface(runtime: Runtime) -> None
Detect the active user interface and configure runtime display defaults.
| PARAMETER | DESCRIPTION |
|---|---|
runtime
|
Runtime whose UI configuration should be updated.
TYPE:
|
Source code in src/omnipy/hub/ui.py
detect_dark_background
detect_dark_background(ui_type: UserInterfaceType.Literals) -> bool
Detect whether the active UI should be treated as using a dark background.
| PARAMETER | DESCRIPTION |
|---|---|
ui_type
|
User-interface type to inspect.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
|
Source code in src/omnipy/hub/ui.py
detect_dark_terminal_background
Detect whether the current terminal background is dark.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
|
| RAISES | DESCRIPTION |
|---|---|
ModuleNotFoundError
|
If the optional |
Notes
Detection depends on terminal capabilities and environment variables.
Source code in src/omnipy/hub/ui.py
detect_display_color_system
detect_display_color_system(
ui_type: SpecifiedUserInterfaceType.Literals,
) -> DisplayColorSystem.Literals
Detect the display color system available for a specific UI type.
| PARAMETER | DESCRIPTION |
|---|---|
ui_type
|
User-interface type to inspect. |
| RETURNS | DESCRIPTION |
|---|---|
DisplayColorSystem.Literals
|
The detected display color system. |
Source code in src/omnipy/hub/ui.py
detect_ui_type
detect_ui_type() -> AutoDetectableUserInterfaceType.Literals
Detect the current Omnipy user-interface type from the execution environment.
| RETURNS | DESCRIPTION |
|---|---|
AutoDetectableUserInterfaceType.Literals
|
The detected user-interface type literal. |
Source code in src/omnipy/hub/ui.py
display_jupyter_setup_note
display_jupyter_setup_note(detected_ui_type: JupyterUserInterfaceType.Literals)
Display setup guidance after Omnipy detects a Jupyter environment.
| PARAMETER | DESCRIPTION |
|---|---|
detected_ui_type
|
Detected Jupyter user-interface type. |
| RAISES | DESCRIPTION |
|---|---|
AssertionError
|
If a non-Jupyter-in-browser type reaches the browser-only branch. |
Source code in src/omnipy/hub/ui.py
get_terminal_prompt_height
get_terminal_prompt_height(ui_type: TerminalOutputUserInterfaceType.Literals) -> int
Return the prompt height for a terminal-oriented UI type.
| PARAMETER | DESCRIPTION |
|---|---|
ui_type
|
Terminal-oriented user-interface type. |
| RETURNS | DESCRIPTION |
|---|---|
int
|
The prompt height in rendered terminal rows. |
Source code in src/omnipy/hub/ui.py
note_mime_bundle
note_mime_bundle(
bullet: str,
html_content: str,
plain_text_content: str = "",
styling: str = "",
noscript: bool = False,
) -> dict[str, str]
Build a MIME bundle for displaying a note in rich frontends.
| PARAMETER | DESCRIPTION |
|---|---|
bullet
|
Leading marker shown beside the note.
TYPE:
|
html_content
|
HTML body to render.
TYPE:
|
plain_text_content
|
Optional plain-text fallback.
TYPE:
|
styling
|
Optional CSS to embed with the note.
TYPE:
|
noscript
|
Whether to wrap the HTML content in
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, str]
|
A MIME bundle suitable for IPython display APIs. |
Example
note_mime_bundle('ℹ️', 'Info')['text/html'] '
...'Source code in
src/omnipy/hub/ui.py
running_in_any_jupyter
Return whether the current session is running in any Jupyter kernel.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
|
Notes
Depends on the active Python execution environment.
Source code in src/omnipy/hub/ui.py
running_in_atty_terminal
Return whether standard output is attached to an interactive terminal.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
|
Notes
Depends on the active standard-output stream.
Source code in src/omnipy/hub/ui.py
running_in_ipython_pycharm
Return whether the current session is running in PyCharm's IPython console.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
|
Notes
Depends on the active Python execution environment.
Source code in src/omnipy/hub/ui.py
running_in_ipython_terminal
Return whether the current session is running in an IPython terminal.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
|
Notes
Depends on the active Python execution environment.
Source code in src/omnipy/hub/ui.py
running_in_jupyter_in_browser
Return whether the current session is running in browser-hosted Jupyter.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
|
Notes
Depends on the active Python execution environment.
Source code in src/omnipy/hub/ui.py
running_in_jupyter_in_pycharm
Return whether the current session is running in PyCharm-hosted Jupyter.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
|
Notes
Depends on the active Python execution environment.
Source code in src/omnipy/hub/ui.py
running_in_pycharm_console
Return whether the current process is hosted by a PyCharm console.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
|
Notes
Depends on the active process environment variables.
Source code in src/omnipy/hub/ui.py
setup_displayhook_if_plain_terminal
setup_displayhook_if_plain_terminal(ui_type: TerminalOutputUserInterfaceType.Literals) -> None
Install Omnipy's display hook for plain-terminal environments.
| PARAMETER | DESCRIPTION |
|---|---|
ui_type
|
Terminal-oriented user-interface type for rendering output. |
Source code in src/omnipy/hub/ui.py
setup_jupyter_ui
Set up Omnipy's rich Jupyter display integration.
Call this once per Jupyter kernel after importing Omnipy. The function injects CSS and hidden reactive widgets that Omnipy uses to track theme changes and available display size, so notebook outputs render and resize correctly.
| RAISES | DESCRIPTION |
|---|---|
AssertionError
|
If the active runtime is not configured for a Jupyter interface. |
Source code in src/omnipy/hub/ui.py
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 | |