On Jan 23, 2017, at 1:06 PM, Vivek Dwivedi <[email protected]> wrote:
Hi Bryan:
Thank you for your reply. However I'm not to sure how i can use the custom tag for the on_click method...
If we set up our toggle buttons:
Tog_Ar = Toggle(label="Argon Off", button_type = "success")
Tog_Ar.tags = [["State","OFF"]]
Tog_TMA = Toggle(label="TMA", type = "success")
Tog_WATER = Toggle(label="WATER", type = "success")
Tog_DEZn = Toggle(label="DEZn", type = "success")
Tog_O2 = Toggle(label="TiF4", type = "success")
Tog_Ellip = Toggle(label="Ellipsometer", type = "success")
and if we define a new tag that has a specific value for each toggle
Tog_Ar.tags = ["IO","EIO0"]
Tog_TMA.tags = ["IO","EIO1"]
ect.
and if we define a python execution such that
ValveOn("IO",1)
ValveOFF("IO",0)
Where "IO" is "EIO0" or "EIO1" tags depending on which toggle we choose
how do we define the toggle_handler function such that on the first click we chose ValveOn("IO",1) and on the second click we choose ValveOn("IO",0) with "IO" being the tag value for each toggle?
I'm having a tough time wrapping my head around the on_click method.
Thanks.
--Vivek
On Monday, January 23, 2017 at 12:26:01 PM UTC-5, Bryan Van de ven wrote:
You can't define new data, but there is a .tags attribute on all Bokeh models that is just a list where you can put whatever bits of data you like, that you could access from CustomJS callbacks, or python server callbacks, etc:
from bokeh.plotting import figure, output_file, show
output_file("border.html")
p = figure(plot_width=400, plot_height=400)
p.tags = ["foo", 10]
p.circle([1,2,3,4,5], [2,5,8,2,7], size=10)
show(p)
For 0.12.5 there will be a "Namespace" feature that will let users essentially create and define named variables that can be shared and synced between BokehJS and Python.
Thanks,
Bryan
> On Jan 23, 2017, at 11:21 AM, Vivek Dwivedi <[email protected]> wrote:
>
> Ok thank you. For the button widget is there a way to define new attributes? Such as on or off or some type of metadata text?
>
> Thanks.
>
> Sent from my iPhone
>
> On Jan 23, 2017, at 11:19 AM, azp...@gmail.com wrote:
>
>> I don't believe that there is a way to determine the changed object directly from the callback arguments, however you can always pass the context (the actuator) with some sort of function argument currying, such as with functools.partial: 9.8. functools — Higher-order functions and operations on callable objects — Python 2.7.18 documentation
>>
>> - Andy
>>
>> On Sunday, January 22, 2017 at 10:24:36 PM UTC-5, Vivek Dwivedi wrote:
>> Greetings...
>>
>> I am interested in knowing if there is a way to use a single update function for toggle buttons. I would like to create a total of 6 toggle buttons:
>>
>> #Setup Toggle Button Widget
>> Tog_Ar = Toggle(label="Argon Off", type = "success")
>> Tog_TMA = Toggle(label="TMA", type = "success")
>> Tog_WATER = Toggle(label="WATER", type = "success")
>> Tog_DEZn = Toggle(label="DEZn", type = "success")
>> Tog_O2 = Toggle(label="TiF4", type = "success")
>> Tog_Ellip = Toggle(label="Ellipsometer", type = "success")
>>
>> And each button when clicked will turn on or off an actuator via a simple external python command that has already been written and tested and that command looks like this:
>>
>> ljm.Actuator(Name,State)
>>
>> where Name is the actuator name, i.e. Tog_Ar from the above button name is the Ar actuator and the State is either "On" or "Off".
>>
>> I would like to use the :
>>
>> Tog_Ar.on_click(toggle_handler)
>>
>> with a generalized toggle_handler function such that:
>>
>> #On Click
>> def toggle_handler(attr, old, new):
>> if attr is active:
>> ljm.Actuator(Name,OFF)
>> else:
>> ljm.Actuator(Name,ON)
>>
>>
>> My preference is to not write a seperate toggle_handler for each button. Is this possible?
>>
>> Thanks.
>>
>> --V
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+un...@continuum.io.
>> To post to this group, send email to bo...@continuum.io.
>> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/e9e75456-a0fb-494c-b35c-ed62bd05752d%40continuum.io\.
>> For more options, visit https://groups.google.com/a/continuum.io/d/optout\.
>
> --
> You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+un...@continuum.io.
> To post to this group, send email to bo...@continuum.io.
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/559C1732-FFE6-47B1-BF4D-1577CFFBB28F%40gmail.com\.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout\.
--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/88c8bb13-4276-4911-9a90-630a09785e4c%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.