def create_navigator_1d(self):
import ipywidgets as ipyw
x_min, x_max = 0, self.signal.axes_manager.navigation_size - 1
x_text = ipyw.BoundedIntText(value=self.indices[0],
description="Coordinate", min=x_min,
max=x_max,
layout=ipyw.Layout(flex='0 1 auto',
width='auto'))
randomize = ipyw.Button(description="Randomize",
layout=ipyw.Layout(flex='0 1 auto',
width='auto'))
container = ipyw.HBox((x_text, randomize))
def on_index_change(change):
self.indices = (x_text.value,)
self.replot_image()
def on_randomize(change):
from random import randint
x = randint(x_min, x_max)
x_text.value = x
x_text.observe(on_index_change, names='value')
randomize.on_click(on_randomize)
return container
评论列表
文章目录