def __init__(self, value): self.taille_ligne = len(value.board.plateau[0]) self.value = value self.items = [] GridBox.__init__(self) self.layout = ipywidgets.Layout(grid_template_columns="repeat(" + str(self.taille_ligne) + ", 50px)", grid_column_gap="1px") self.create()
def _init_grid(self): # Set up scales for the spatial x, spatial y, spectral, and flux self.scale_x = bqplot.LinearScale(min=0, max=1) self.scale_y = bqplot.LinearScale(min=0, max=1) self.scale_spec = bqplot.LinearScale(min=0, max=1) self.scale_flux = bqplot.LinearScale(min=0, max=1) # Set up colorscale self.scale_cutout_image = ColorScale(colors=['black', 'white']) self.scale_spec2d_image = ColorScale(colors=['black', 'white']) # Set up axes self.axis_x = bqplot.Axis(scale=self.scale_x, grid_lines='solid', label='x') self.axis_y = bqplot.Axis(scale=self.scale_y, grid_lines='solid', label='y', orientation='vertical') self.axis_spec = bqplot.Axis(scale=self.scale_spec, grid_lines='solid', label='spec') self.axis_flux = bqplot.Axis(scale=self.scale_flux, grid_lines='solid', label='flux', orientation='vertical') # Set up bqplot viewers # ===================== # Cutout # ------ self.fig_cutout = bqplot.Figure(scales={ 'x': self.scale_x, 'y': self.scale_y }, axes=[self.axis_x, self.axis_y], layout={ 'width': '500px', 'height': '400px' }) self.fig_cutout.interaction = PanZoom(scales={ 'x': [self.scale_x], 'y': [self.scale_y] }) # Spec 2d # ------- self.fig_spec2d = bqplot.Figure(scales={ 'x': self.scale_spec, 'y': self.scale_y }, axes=[self.axis_spec, self.axis_y], layout={ 'width': '500px', 'height': '400px' }) self.fig_spec2d.interaction = PanZoom(scales={ 'x': [self.scale_spec], 'y': [self.scale_y] }) # Spec 1d # ------- self.fig_spec1d = bqplot.Figure(scales={ 'x': self.scale_spec, 'y': self.scale_flux }, axes=[self.axis_spec, self.axis_flux], layout={ 'width': '500px', 'height': '400px' }) self.fig_spec1d.interaction = PanZoom(scales={ 'x': [self.scale_spec], 'y': [self.scale_flux] }) # info box # -------- self.info_box = Textarea(value='Hello World') self.info_box.layout.height = '100%' self.info_box.layout.width = '100%' self.info_box.layout.align_self = 'flex-end' # Set up content of figures # ========================= self.cutout_mark = AstroImage(scales={ 'x': self.scale_x, 'y': self.scale_y, 'image': self.scale_cutout_image }) self.fig_cutout.marks = [self.cutout_mark] self.spec2d_mark = AstroImage( scales={ 'x': self.scale_spec, 'y': self.scale_y, 'image': self.scale_spec2d_image }) self.fig_spec2d.marks = [self.spec2d_mark] self.spec1d_mark = bqplot.Lines(scales={ 'x': self.scale_spec, 'y': self.scale_flux }, x=[], y=[]) self.fig_spec1d.marks = [self.spec1d_mark] GridBox.__init__(self, [ self.fig_cutout, HTML(), self.fig_spec2d, HTML(), HTML(), HTML(), self.info_box, HTML(), self.fig_spec1d ], layout=Layout(width='100%', grid_template_columns='35% 5% 35%', grid_template_rows='30% 5% 30%', grid_gap='30px 30px')) self.layout.justify_content = "center" self.layout.align_items = "center"