ipywidgets

Python ipywidgets checkbox events

佐手、 提交于 2020-01-02 15:54:38
问题 I am using ipywidgets.widgets.Checkbox. Is there any way to handle the checkbox events? Please do help. I am a beginner. edit: How to create a list of checkboxes? 回答1: There aren't any direct events but you can use the observe event. That will likely create more events than you want so you may want to filter them down to one. from IPython.display import display from ipywidgets import Checkbox box = Checkbox(False, description='checker') display(box) def changed(b): print(b) box.observe

Really confused with Jupyter Notebook, Lab, extensions, and ipywidgets

你说的曾经没有我的故事 提交于 2020-01-01 08:24:27
问题 I want to create an interactive JupyterLab Notebook application, and I need to create a series of custom Widgets. So I started looking into this matter, and the more I look the more confused I become. To make things simple I will ask a bunch of simple questions: One of the most common ways to use widgets on Jupyter Notebooks is to use the ipywidgets library. Right? Unlike the classic Notebook, the Notebook of JupyterLab cannot render JavaScript directly. As a result, the tutorials about

Really confused with Jupyter Notebook, Lab, extensions, and ipywidgets

元气小坏坏 提交于 2020-01-01 08:24:09
问题 I want to create an interactive JupyterLab Notebook application, and I need to create a series of custom Widgets. So I started looking into this matter, and the more I look the more confused I become. To make things simple I will ask a bunch of simple questions: One of the most common ways to use widgets on Jupyter Notebooks is to use the ipywidgets library. Right? Unlike the classic Notebook, the Notebook of JupyterLab cannot render JavaScript directly. As a result, the tutorials about

ipywidgets: Update one widget based on results from another

寵の児 提交于 2019-12-30 03:23:04
问题 I am using widgets in IPython that allows the user to repeatedly search for a phrase and see the results (different titles) in another widget (a selection widget) and then select one of the results. In short: search_text = widgets.Text(description = 'Search') search_result = widgets.Select(description = 'Select table') def search_action(sender): phrase = search_text.value df = search(phrase) # A function that returns the results in a pandas df titles = df['title'].tolist() search_result

How to lazify output in Tabbed Layout in jupyter notebook?

百般思念 提交于 2019-12-24 09:59:43
问题 I want to create a tabbed layout in jupyter notebook using ipywidgets . I want to process the output of a particular tab only when it is clicked. In other words, lazify the output. from ipywidgets import widgets out1 = widgets.Output() with out1: get_output_1() out2 = widgets.Output() with out2: get_output_2() out = widgets.Tab([out1, out2]) out.set_title(0, 'out1') out.set_title(1, 'out2') display(out) I want the functions get_output_1() and get_output_2() to be called only when the

Container as tooltip doesn't show contents

南楼画角 提交于 2019-12-24 08:24:39
问题 I'm creating a scatterplot and want to show some information in a tooltip. The following works perfectly: import bqplot as bqp import ipywidgets as ipw xSc = bqp.LinearScale() ySc = bqp.LinearScale() tt = ipw.Label("A") def hover_handler(self, content): tt.value = str(content) s = bqp.Scatter(x=[0, 1, 2], y=[1, 2, 3], scales=dict(x=xSc, y=ySc), tooltip=tt) s.on_hover(hover_handler) bqp.Figure(marks=[s]) (there's no axes and whatnot to keep the code short) Hovering over each point shows its

How to pause Jupyter Notebook widgets, waiting for user input

橙三吉。 提交于 2019-12-24 07:06:29
问题 In my notebook I've a loop in which I want to ask the user to binary "Yes" or "No". On this choice the algorithm is suppposed to continue. for i in range(n_total): display.clear_output(wait=True) waiting_for_scoring = True print("True or False?") display.display(widgets.HBox((true_button, false_button))) a = true_button.on_click(on_true_button) a = false_button.on_click(on_false_button) while waiting_for_scoring == True: #waiting for user input pass How can I make the loop to wait, after the

How to change multiple interactive plots with a single input in Python

亡梦爱人 提交于 2019-12-22 09:35:50
问题 I am trying to make several interactive plots with the ipywidgets library in Jupyter Notebook. I face however one problem: I try to make multiple plots change when one single input widget changes, for example a slider. In the added MWE this is illustrated with a sine and cosine function that both depend on a single input widget that sets the amplitude of both the sine and the cosine function. Thus, if the value of the input slider is set at the value 2, the amplitude of both the sine and

how to fix - error: bad escape \u at position 0

不羁的心 提交于 2019-12-18 07:11:35
问题 Hello I'm trying to export a gmap html using ipywidgets in jupyter notebook but am encountering the following error: - error: bad escape \u at position 0. I'm new to programing and could use help fixing whatever is causing this error to occur. If there is any easier way to go about exporting the html file I'm happy to change approaches. Thanks Here is a snippet of the code: I can add the entire thing if its helpful. import pandas as pd import gmaps from ipywidgets.embed import embed_minimal

Add HBox to VBox using Button after creation

北城余情 提交于 2019-12-13 03:15:04
问题 I am trying to make an input widget for a module i have made. The input widget should have a title bar and a variable number of input lines below. I had in mind to have an add button which should add a line directly below the title line. I have tried following this stackoverflow question and this issue on github. But these suggestions only add a widget to the bottom of the VBox. I have made the following dummy example. import ipywidgets as w def add_button_clicked(b): #This adds new line at