Ipywidgets box
In [1]:
Copied!
# import geemap
# Map = geemap.Map()
# Map
# import geemap
# Map = geemap.Map()
# Map
In [2]:
Copied!
import ipywidgets as widgets
import ipywidgets as widgets
In [3]:
Copied!
widget_width = "250px"
padding = "0px 0px 0px 4px" # upper, right, bottom, left
widget_width = "250px"
padding = "0px 0px 0px 4px" # upper, right, bottom, left
In [4]:
Copied!
toolbar_button = widgets.ToggleButton(
value=False,
tooltip="Toolbar",
icon="gear",
layout=widgets.Layout(width="28px", height="28px", padding=padding),
)
toolbar_button
toolbar_button = widgets.ToggleButton(
value=False,
tooltip="Toolbar",
icon="gear",
layout=widgets.Layout(width="28px", height="28px", padding=padding),
)
toolbar_button
Out[4]:
In [5]:
Copied!
# toolbar_button.layout.width = "28px"
# toolbar_button.layout.width = "28px"
In [6]:
Copied!
toolbar_button.value
toolbar_button.value
Out[6]:
False
In [7]:
Copied!
close_button = widgets.ToggleButton(
value=False,
tooltip="Close the tool",
icon="times",
button_style="primary",
layout=widgets.Layout(height="28px", width="28px", padding=padding),
)
close_button
close_button = widgets.ToggleButton(
value=False,
tooltip="Close the tool",
icon="times",
button_style="primary",
layout=widgets.Layout(height="28px", width="28px", padding=padding),
)
close_button
Out[7]:
In [8]:
Copied!
widgets.HBox([close_button, toolbar_button])
widgets.HBox([close_button, toolbar_button])
Out[8]:
In [9]:
Copied!
box = widgets.HBox()
box.children = [close_button, toolbar_button]
box
box = widgets.HBox()
box.children = [close_button, toolbar_button]
box
Out[9]:
In [10]:
Copied!
checkbox = widgets.Checkbox(
description="Checkbox",
indent=False,
layout=widgets.Layout(padding=padding, width=widget_width),
)
checkbox
checkbox = widgets.Checkbox(
description="Checkbox",
indent=False,
layout=widgets.Layout(padding=padding, width=widget_width),
)
checkbox
Out[10]:
In [11]:
Copied!
dropdown = widgets.Dropdown(
options=["Option 1", "Option 2", "Option 3"],
value=None,
description="Dropdown:",
layout=widgets.Layout(width=widget_width, padding=padding),
style={"description_width": "initial"},
)
dropdown
dropdown = widgets.Dropdown(
options=["Option 1", "Option 2", "Option 3"],
value=None,
description="Dropdown:",
layout=widgets.Layout(width=widget_width, padding=padding),
style={"description_width": "initial"},
)
dropdown
Out[11]:
In [12]:
Copied!
int_slider = widgets.IntSlider(
min=1,
max=100,
description="Int Slider: ",
readout=True,
continuous_update=True,
layout=widgets.Layout(width=widget_width, padding=padding),
style={"description_width": "initial"},
)
int_slider
int_slider = widgets.IntSlider(
min=1,
max=100,
description="Int Slider: ",
readout=True,
continuous_update=True,
layout=widgets.Layout(width=widget_width, padding=padding),
style={"description_width": "initial"},
)
int_slider
Out[12]:
In [13]:
Copied!
float_slider = widgets.FloatSlider(
min=1,
max=100,
description="Float Slider: ",
readout=True,
continuous_update=True,
layout=widgets.Layout(width=widget_width, padding=padding),
style={"description_width": "initial"},
)
float_slider = widgets.FloatSlider(
min=1,
max=100,
description="Float Slider: ",
readout=True,
continuous_update=True,
layout=widgets.Layout(width=widget_width, padding=padding),
style={"description_width": "initial"},
)
In [14]:
Copied!
color = widgets.ColorPicker(
concise=False,
description="Color:",
value="white",
style={"description_width": "initial"},
layout=widgets.Layout(width=widget_width, padding=padding),
)
color
color = widgets.ColorPicker(
concise=False,
description="Color:",
value="white",
style={"description_width": "initial"},
layout=widgets.Layout(width=widget_width, padding=padding),
)
color
Out[14]:
In [15]:
Copied!
text = widgets.Text(
value="",
description="Textbox:",
placeholder="Enter sth.",
style={"description_width": "initial"},
layout=widgets.Layout(width=widget_width, padding=padding),
)
text
text = widgets.Text(
value="",
description="Textbox:",
placeholder="Enter sth.",
style={"description_width": "initial"},
layout=widgets.Layout(width=widget_width, padding=padding),
)
text
Out[15]:
In [16]:
Copied!
textarea = widgets.Textarea(
placeholder="Placeholder",
layout=widgets.Layout(width=widget_width),
)
textarea
textarea = widgets.Textarea(
placeholder="Placeholder",
layout=widgets.Layout(width=widget_width),
)
textarea
Out[16]:
In [17]:
Copied!
buttons = widgets.ToggleButtons(
value=None,
options=["Apply", "Reset", "Close"],
tooltips=["Apply", "Reset", "Close"],
button_style="primary",
)
buttons.style.button_width = "80px"
buttons
buttons = widgets.ToggleButtons(
value=None,
options=["Apply", "Reset", "Close"],
tooltips=["Apply", "Reset", "Close"],
button_style="primary",
)
buttons.style.button_width = "80px"
buttons
Out[17]:
In [18]:
Copied!
output = widgets.Output(layout=widgets.Layout(width=widget_width, padding=padding))
with output:
output.clear_output()
print("Running ...")
output
output = widgets.Output(layout=widgets.Layout(width=widget_width, padding=padding))
with output:
output.clear_output()
print("Running ...")
output
Out[18]:
In [19]:
Copied!
toolbar_widget = widgets.VBox()
toolbar_widget.children = [
widgets.HBox([close_button, toolbar_button]),
checkbox,
int_slider,
float_slider,
dropdown,
text,
color,
textarea,
buttons,
output,
]
toolbar_widget
toolbar_widget = widgets.VBox()
toolbar_widget.children = [
widgets.HBox([close_button, toolbar_button]),
checkbox,
int_slider,
float_slider,
dropdown,
text,
color,
textarea,
buttons,
output,
]
toolbar_widget
Out[19]:
Last update:
2023-05-10