peakfinder2D_gui.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:pyxem 作者: pyxem 项目源码 文件源码
def create_navigator_2d(self):
        import ipywidgets as ipyw
        x_min, y_min = 0, 0
        x_max, y_max = self.signal.axes_manager.navigation_shape
        x_max -= 1
        y_max -= 1
        x_text = ipyw.BoundedIntText(value=self.indices[0], description="x",
                                     min=x_min, max=x_max,
                                     layout=ipyw.Layout(flex='0 1 auto',
                                                        width='auto'))
        y_text = ipyw.BoundedIntText(value=self.indices[1], description="y",
                                     min=y_min, max=y_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, y_text, randomize))

        def on_index_change(change):
            self.indices = (x_text.value, y_text.value)
            self.replot_image()

        def on_randomize(change):
            from random import randint
            x = randint(x_min, x_max)
            y = randint(y_min, y_max)
            x_text.value = x
            y_text.value = y

        x_text.observe(on_index_change, names='value')
        y_text.observe(on_index_change, names='value')
        randomize.on_click(on_randomize)
        return container
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号