本文整理汇总了Python中ipywidgets.interactive方法的典型用法代码示例。如果您正苦于以下问题:Python ipywidgets.interactive方法的具体用法?Python ipywidgets.interactive怎么用?Python ipywidgets.interactive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ipywidgets
的用法示例。
在下文中一共展示了ipywidgets.interactive方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _interact_frequency
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import interactive [as 别名]
def _interact_frequency(self,freq_val,min_freq=87.5,max_freq=108,freq_step=0.2):
'''
Sets up tuning frequency slider widget for Mono FM Example
'''
self.slider = FloatSlider(
value=freq_val,
min=min_freq,
max=max_freq,
step=freq_step,
description=r'$f_c\;$',
continuous_update=False,
orientation='horizontal',
readout_format='0.1f',
layout=Layout(
width='90%',
)
)
self.slider.style.handle_color = 'lightblue'
self.center_freq_widget = interactive(self.set_fc_mhz, fc = self.slider)
display(self.center_freq_widget)
示例2: _interact_audio_gain
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import interactive [as 别名]
def _interact_audio_gain(self,gain_val=0,min_gain=-60,max_gain=6,gain_step=0.1):
'''
Sets up audio gain slider widget for Mono FM Example
'''
self.gain_slider = FloatSlider(
value=gain_val,
min=min_gain,
max=max_gain,
step=gain_step,
description='Gain (dB)',
continuous_update=True,
orientation='horizontal',
readout_format='0.1f',
layout=Layout(
width='90%',
)
)
self.gain_slider.style.handle_color = 'lightgreen'
self.audio_gain_widget = interactive(self.set_audio_gain_db,gain=self.gain_slider)
display(self.audio_gain_widget)
示例3: _widgets
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import interactive [as 别名]
def _widgets(self):
dfrange = self.varr.range('frame')
w_frame = iwgt.IntSlider(
value=0,
min=dfrange[0],
max=dfrange[1],
continuous_update=False,
description="Frame:")
w_paly = iwgt.Play(
value=0,
min=dfrange[0],
max=dfrange[1],
interval=1000 / self.framerate)
iwgt.jslink((w_paly, 'value'), (w_frame, 'value'))
iwgt.interactive(self.stream.event, f=w_frame)
return iwgt.HBox([w_paly, w_frame])
示例4: _widgets
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import interactive [as 别名]
def _widgets(self):
dfrange = self.ds.range('frame')
w_frame = iwgt.IntSlider(
value=0,
min=dfrange[0],
max=dfrange[1],
continuous_update=False,
description="Frame:")
w_paly = iwgt.Play(
value=0,
min=dfrange[0],
max=dfrange[1],
interval=1000 / self.framerate)
iwgt.jslink((w_paly, 'value'), (w_frame, 'value'))
iwgt.interactive(self.stream.event, f=w_frame)
return iwgt.HBox([w_paly, w_frame])
示例5: interactive
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import interactive [as 别名]
def interactive( animation, size = 320 ):
basedir = mkdtemp()
basename = join( basedir, 'graph' )
steps = [ Image( path ) for path in render( animation.graphs(), basename, 'png', size ) ]
rmtree( basedir )
slider = widgets.IntSlider( min = 0, max = len( steps ) - 1, step = 1, value = 0 )
return widgets.interactive( lambda n: display(steps[ n ]), n = slider )
示例6: interactive_FM_Rx
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import interactive [as 别名]
def interactive_FM_Rx(self,fc=103.9e6,gain=40,audio_out=1,audio_buffsize=4096,audio_fs=48000):
'''
Sets up interactive mono FM example
'''
self.set_fs(2.4e6)
self.set_fc(fc)
self.set_gain(gain)
self.set_audio_in(0)
self.set_audio_out(audio_out)
self.set_audio_buffsize(audio_buffsize)
self.set_audio_fs(audio_fs)
self.togglebutts = ToggleButtons(
options=['Start Streaming', 'Stop Streaming'],
description = ' ',
value = 'Stop Streaming',
)
self.togglebutts.style.button_width = "400px"
self.togglebutts.style.description_width = "1px"
self.play = interactive(self._interaction, Stream = self.togglebutts)
title = widgets.Output()
title.append_stdout("Interactive FM Receiver")
display(title)
display(self.play)
self._interact_audio_gain()
self._interact_frequency(self.fc/1e6)
示例7: interactive_stream
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import interactive [as 别名]
def interactive_stream(self,Tsec = 2, numChan = 1):
"""
Stream audio with start and stop radio buttons
Interactive stream is designed for streaming audio through this object using
a callback function. This stream is threaded, so it can be used with ipywidgets.
Click on the "Start Streaming" button to start streaming and click on "Stop Streaming"
button to stop streaming.
Parameters
----------
Tsec : stream time in seconds if Tsec > 0. If Tsec = 0, then stream goes to infinite
mode. When in infinite mode, the "Stop Streaming" radio button or Tsec.stop() can be
used to stop the stream.
numChan : number of channels. Use 1 for mono and 2 for stereo.
"""
self.Tsec = Tsec
self.numChan = numChan
self.interactiveFG = 1
self.play = interactive(self.interaction,Stream = ToggleButtons(
options=['Start Streaming', 'Stop Streaming'],
description = ' ',
value = 'Stop Streaming') )
display(self.play)
示例8: ipy_plot_interactive_annotate
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import interactive [as 别名]
def ipy_plot_interactive_annotate(df, ind, opacity=.3):
import plotly.graph_objs as go
from ipywidgets import interactive
if 'labels' in df.columns:
text = [f'Class {k}: index {i}' for i,k in zip(df.index, df.labels)] # hovertext
else:
text = [f'index {i}' for i in df.index] # hovertext
xaxis, yaxis = df.columns[0], df.columns[1]
scatter = go.Scattergl(x=df[xaxis],
y=df[yaxis],
mode='markers',
text=text,
marker=dict(size=2,
opacity=opacity,
))
sub = df.loc[ind]
text = [f'{k}){i}' for i,k in zip(sub.index, sub.labels)]
scatter2 = go.Scatter(x=sub[xaxis],
y=sub[yaxis],
mode='markers+text',
text=text,
textposition="top center",
textfont=dict(size=9,color='black'),
marker=dict(size=5,color='black'))
f = go.FigureWidget([scatter,scatter2])
f.update_layout(xaxis_title=xaxis, yaxis_title=yaxis)
def update_axes(xaxis, yaxis, color_by, colorscale):
scatter = f.data[0]
scatter.x = df[xaxis]
scatter.y = df[yaxis]
scatter.marker.colorscale = colorscale
if colorscale is None:
scatter.marker.color = None
else:
scatter.marker.color = df[color_by] if color_by != 'index' else df.index
scatter2 = f.data[1]
scatter2.x = sub[xaxis]
scatter2.y = sub[yaxis]
with f.batch_update(): # what is this for??
f.layout.xaxis.title = xaxis
f.layout.yaxis.title = yaxis
widget = interactive(update_axes,
yaxis = df.select_dtypes('number').columns,
xaxis = df.select_dtypes('number').columns,
color_by = df.columns,
colorscale = [None,'hsv','plotly3','deep','portland','picnic','armyrose'])
return widget, f
示例9: ipy_plot_interactive
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import interactive [as 别名]
def ipy_plot_interactive(df, opacity=.3):
import plotly.graph_objs as go
from ipywidgets import interactive
if 'labels' in df.columns:
text = [f'Class {k}: index {i}' for i,k in zip(df.index, df.labels)] # hovertext
else:
text = [f'index {i}' for i in df.index] # hovertext
xaxis, yaxis = df.columns[0], df.columns[1]
f = go.FigureWidget([go.Scattergl(x=df[xaxis],
y=df[yaxis],
mode='markers',
text=text,
marker=dict(size=2,
opacity=opacity,
color=np.arange(len(df)),
colorscale='hsv'
))])
scatter = f.data[0]
N = len(df)
f.update_layout(xaxis_title=xaxis, yaxis_title=yaxis)
f.layout.dragmode = 'lasso'
def update_axes(xaxis, yaxis, color_by, colorscale):
scatter = f.data[0]
scatter.x = df[xaxis]
scatter.y = df[yaxis]
scatter.marker.colorscale = colorscale
if colorscale is None:
scatter.marker.color = None
else:
scatter.marker.color = df[color_by] if color_by != 'index' else df.index
with f.batch_update(): # what is this for??
f.layout.xaxis.title = xaxis
f.layout.yaxis.title = yaxis
widget = interactive(update_axes,
yaxis=df.select_dtypes('number').columns,
xaxis=df.select_dtypes('number').columns,
color_by = df.columns,
colorscale = [None,'hsv','plotly3','deep','portland','picnic','armyrose'])
t = go.FigureWidget([go.Table(
header=dict(values=['index']),
cells=dict(values=[df.index]),
)])
def selection_fn(trace, points, selector):
t.data[0].cells.values = [df.loc[points.point_inds].index]
scatter.on_selection(selection_fn)
return widget, f, t