MCPcopy
hub / github.com/gee-community/geemap / widget_template

Function widget_template

geemap/coreutils.py:488–618  ·  view source on GitHub ↗

Create a widget template. Args: widget: The widget to be displayed. opened: Whether to open the toolbar. show_close_button: Whether to show the close button. widget_icon: The icon name for the toolbar button. close_button_icon: The icon name for the close

(
    widget: ipywidgets.Widget | None = None,
    opened: bool = True,
    show_close_button: bool = True,
    widget_icon: str = "gear",
    close_button_icon: str = "times",
    widget_args: dict[str, Any] | None = None,
    close_button_args: dict[str, Any] | None = None,
    display_widget: ipywidgets.Widget | None = None,
    m: ipyleaflet.Map | None = None,
    position: str = "topright",
)

Source from the content-addressed store, hash-verified

486
487
488def widget_template(
489 widget: ipywidgets.Widget | None = None,
490 opened: bool = True,
491 show_close_button: bool = True,
492 widget_icon: str = "gear",
493 close_button_icon: str = "times",
494 widget_args: dict[str, Any] | None = None,
495 close_button_args: dict[str, Any] | None = None,
496 display_widget: ipywidgets.Widget | None = None,
497 m: ipyleaflet.Map | None = None,
498 position: str = "topright",
499) -> ipywidgets.Widget | None:
500 """Create a widget template.
501
502 Args:
503 widget: The widget to be displayed.
504 opened: Whether to open the toolbar.
505 show_close_button: Whether to show the close button.
506 widget_icon: The icon name for the toolbar button.
507 close_button_icon: The icon name for the close button.
508 widget_args: Additional arguments to pass to the toolbar button.
509 close_button_args: Additional arguments to pass to the close button.
510 display_widget: The widget to be displayed when the toolbar is clicked.
511 m: The ipyleaflet.Map instance.
512 position: The position of the toolbar.
513
514 Returns:
515 The created widget template.
516 """
517 name = "_" + random_string() # A random attribute name.
518
519 if widget_args is None:
520 widget_args = {}
521
522 if close_button_args is None:
523 close_button_args = {}
524
525 if "value" not in widget_args:
526 widget_args["value"] = False
527 if "tooltip" not in widget_args:
528 widget_args["tooltip"] = "Toolbar"
529 if "layout" not in widget_args:
530 widget_args["layout"] = ipywidgets.Layout(
531 width="28px", height="28px", padding="0px 0px 0px 4px"
532 )
533 widget_args["icon"] = widget_icon
534
535 if "value" not in close_button_args:
536 close_button_args["value"] = False
537 if "tooltip" not in close_button_args:
538 close_button_args["tooltip"] = "Close the tool"
539 if "button_style" not in close_button_args:
540 close_button_args["button_style"] = "primary"
541 if "layout" not in close_button_args:
542 close_button_args["layout"] = ipywidgets.Layout(
543 height="28px", width="28px", padding="0px 0px 0px 4px"
544 )
545 close_button_args["icon"] = close_button_icon

Callers

nothing calls this directly

Calls 3

random_stringFunction · 0.85
add_controlMethod · 0.80
observeMethod · 0.45

Tested by

no test coverage detected