I have the following original code where all widgets are displayed along one column only and I would like to display them along 2 columns.
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets
from ipywidgets import Button, HBox, VBox
dW = widgets.Dropdown(options=['2', '1'])
rW = widgets.FloatText(200)
aW = widgets.FloatText(1)
@interact(D=dW, R=rW, A=aW)
def print_p(D, R, A):
dW = D
rW = R
aW = A
I have read the docs and it suggests to use the following format:
left_box = VBox([dW, rW])
right_box = VBox([aW])
HBox([left_box, right_box])
Is there a way to integrate the code above so I do not need to change the original format and see the 2 columns?
Here the answer:
from __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual, Text
import ipywidgets as widgets
dW = widgets.Dropdown(options=['2', '3'])
rW = widgets.FloatText(200)
mW = widgets.FloatText()
left_box = VBox([dW, rW])
right_box = VBox([mW])
ui = HBox([left_box, right_box])
def print_p(Provvigione_Agente_EUR, R, M):
dW = Provvigione_Agente_EUR
rW = R
mW.value = int(dW)*int(rW)
out = widgets.interactive_output(print_p, {'Provvigione_Agente_EUR':dW, 'R':rW, 'M':mW})
display(ui, out)