Ipywidgets box

In [ ]:
Copied!
# import geemap
# Map = geemap.Map()
# Map
# import geemap
# Map = geemap.Map()
# Map
In [1]:
Copied!
import ipywidgets as widgets
import ipywidgets as widgets
In [2]:
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 [3]:
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[3]:
ToggleButton(value=False, icon='gear', layout=Layout(height='28px', padding='0px 0px 0px 4px', width='28px'), …
In [ ]:
Copied!
# toolbar_button.layout.width = "28px"
# toolbar_button.layout.width = "28px"
In [4]:
Copied!
import ipyleaflet
import ipyleaflet
In [6]:
Copied!
control = ipyleaflet.WidgetControl(widget=toolbar_button, position = "topright")
control = ipyleaflet.WidgetControl(widget=toolbar_button, position = "topright")
In [7]:
Copied!
m=ipyleaflet.Map(center=[40,-100], zoom = 4)
m
m=ipyleaflet.Map(center=[40,-100], zoom = 4)
m
Out[7]:
Map(center=[40, -100], controls=(ZoomControl(options=['position', 'zoom_in_text', 'zoom_in_title', 'zoom_out_t…
In [8]:
Copied!
m.add_control(control)
m.add_control(control)
In [10]:
Copied!
toolbar_button.value
toolbar_button.value
Out[10]:
False
In [ ]:
Copied!
In [11]:
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[11]:
ToggleButton(value=False, button_style='primary', icon='times', layout=Layout(height='28px', padding='0px 0px …
In [12]:
Copied!
widgets.HBox([close_button, toolbar_button])
widgets.HBox([close_button, toolbar_button])
Out[12]:
HBox(children=(ToggleButton(value=True, button_style='primary', icon='times', layout=Layout(height='28px', pad…
In [13]:
Copied!
box = widgets.HBox()
box.children = [close_button, toolbar_button]
box
box = widgets.HBox()
box.children = [close_button, toolbar_button]
box
Out[13]:
HBox(children=(ToggleButton(value=True, button_style='primary', icon='times', layout=Layout(height='28px', pad…
In [14]:
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[14]:
Checkbox(value=False, description='Checkbox', indent=False, layout=Layout(padding='0px 0px 0px 4px', width='25…
In [15]:
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[15]:
Dropdown(description='Dropdown:', layout=Layout(padding='0px 0px 0px 4px', width='250px'), options=('Option 1'…
In [16]:
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[16]:
IntSlider(value=1, description='Int Slider: ', layout=Layout(padding='0px 0px 0px 4px', width='250px'), min=1,…
In [20]:
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
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
Out[20]:
FloatSlider(value=1.0, description='Float Slider: ', layout=Layout(padding='0px 0px 0px 4px', width='250px'), …
In [21]:
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[21]:
ColorPicker(value='white', description='Color:', layout=Layout(padding='0px 0px 0px 4px', width='250px'), styl…
In [22]:
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[22]:
Text(value='', description='Textbox:', layout=Layout(padding='0px 0px 0px 4px', width='250px'), placeholder='E…
In [23]:
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[23]:
Textarea(value='', layout=Layout(width='250px'), placeholder='Placeholder')
In [24]:
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[24]:
ToggleButtons(button_style='primary', options=('Apply', 'Reset', 'Close'), style=ToggleButtonsStyle(button_wid…
In [26]:
Copied!
buttons.value
buttons.value
Out[26]:
'Apply'
In [27]:
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[27]:
Output(layout=Layout(padding='0px 0px 0px 4px', width='250px'))
In [28]:
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[28]:
VBox(children=(HBox(children=(ToggleButton(value=False, button_style='primary', icon='times', layout=Layout(he…
In [ ]:
Copied!