You can use traitlets.link to connect two values together.

from IPython.display import displayimport ipywidgets as Wfrom
traitlets import link
def coreCalculationFunction(myOptions):
    return myOptions
def optionsRelatedFunction():
    myOptions=['a', 'b', 'c']
    label = W.HTML(value="Hello World")
    the_interact = W.interactive(coreCalculationFunction,
                 myOptions=myOptions)
    dropdown = the_interact.children[0]

    # link ensures that when dropdown.value changes,
    # label.value gets the same value, and vice versa.
    # dlink is a unidirectional alternative.
    link((dropdown, 'value'),
         (label, 'value'),
    )
    display(label, the_interact)

optionsRelatedFunction()

-MinRK
​


On Sat, Jun 24, 2017 at 10:21 PM, Malitha Kabir <malitha12...@gmail.com>
wrote:

> Hi,
> I am facing trouble with updating widget value. Any help is highly
> appreciated.
>
> Here is relevant details:
> I have two widgets (one dropdown and another html text). My uses will
> change the value from dropdown and will expect to see the effect in html
> text.
> Additional note 1 : my current development uses interact() function. It
> will be great help if you enable me to persist the current structure.
> Additional note 2 : I need to make sure that the development is fit for
> both python 2 and 3.
>
> Here is the relevant architecture:
>
> from __future__ import print_function
> from ipywidgets import interact, interactive, fixed, interact_manual
> import ipywidgets as widgets
>
> def coreCalculationFunction(wantToUpdateIt,myOptions):
>
>     if myOptions is 'a':
>         wantToUpdateIt='first alphabet in english'
>     elif myOptions is 'b':
>         wantToUpdateIt='second alphabet in english'
>     else:
>         wantToUpdateIt='anything else here!'
>
>     return myOptions
>
> def optionsRelatedFunction():
>     myOptions=['a', 'b', 'c']
>     wantToUpdateIt=widgets.HTML(value="Hello World")
>     res=interact(coreCalculationFunction,
>                  wantToUpdateIt=wantToUpdateIt,
>                  myOptions=myOptions);
>     return res
>
>
> optionsRelatedFunction()
>
>
> Thank you very much for your kind help.
>
> Best regards,
> Malitha Humayun Kabir
>
> --
> You received this message because you are subscribed to the Google Groups
> "Project Jupyter" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jupyter+unsubscr...@googlegroups.com.
> To post to this group, send email to jupyter@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/jupyter/c36112ea-bcdf-4fa1-963e-6efd601fb2f7%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jupyter+unsubscr...@googlegroups.com.
To post to this group, send email to jupyter@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/CAHNn8BVN6iFifKZ-5kcOo___meXf5Zfgt89VeiBOsgUZMaMhbw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to