def __init__(self, parent, title, hid): # Forcing a specific style on the window. # Should this include styles passed? style = wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE wx.Frame.__init__(self, parent, title=title, size=wx.Size(850, 650), style=style) imgDir = ut.Path.GetImage() icon = wx.Icon(os.path.join(imgDir, 'h5pyViewer.ico'), wx.BITMAP_TYPE_ICO) self.SetIcon(icon) canvas = GLCanvasImg(self, self.SetStatusCB) t = type(hid) if t == h5py.h5d.DatasetID: ds = h5py.Dataset(hid) self.dataSet = ds sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(canvas, 1, wx.LEFT | wx.TOP | wx.GROW) self.SetSizer(sizer) wxAxCtrlLst = [] l = len(ds.shape) idxXY = (l - 2, l - 1) for idx, l in enumerate(ds.shape): if idx in idxXY: continue wxAxCtrl = ut.SliderGroup(self, label='Axis:%d' % idx, range=(0, l - 1)) wxAxCtrl.idx = idx wxAxCtrlLst.append(wxAxCtrl) sizer.Add(wxAxCtrl.sizer, 0, wx.EXPAND | wx.ALIGN_CENTER | wx.ALL, border=5) wxAxCtrl.SetCallback(self.OnSetView, wxAxCtrl) sl = ut.GetSlice(idxXY, ds.shape, wxAxCtrlLst) canvas.data = ds[sl] #self.Fit() self.Centre() self.canvas = canvas self.sizer = sizer self.idxXY = idxXY self.wxAxCtrlLst = wxAxCtrlLst self.BuildMenu()
def __init__(self, parent, lbl, hid): wx.Frame.__init__(self, parent, title=lbl, size=wx.Size(850, 650)) imgDir = ut.Path.GetImage() icon = wx.Icon(os.path.join(imgDir, 'h5pyViewer.ico'), wx.BITMAP_TYPE_ICO) self.SetIcon(icon) t = type(hid) if t == h5py.h5d.DatasetID: data = h5py.Dataset(hid) canvas = MPLCanvasImg(self, self.SetStatusCB) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(canvas, 1, wx.LEFT | wx.TOP | wx.GROW) self.SetSizer(sizer) toolbar = ut.AddToolbar(canvas, sizer) wxAxCtrlLst = [] l = len(data.shape) idxXY = (l - 2, l - 1) for idx, l in enumerate(data.shape): if idx in idxXY: continue wxAxCtrl = ut.SliderGroup(self, label='Axis:%d' % idx, range=(0, l - 1)) wxAxCtrl.idx = idx wxAxCtrlLst.append(wxAxCtrl) sizer.Add(wxAxCtrl.sizer, 0, wx.EXPAND | wx.ALIGN_CENTER | wx.ALL, border=5) wxAxCtrl.SetCallback(HdfImageFrame.OnSetView, wxAxCtrl) sl = ut.GetSlice(idxXY, data.shape, wxAxCtrlLst) canvas.InitChild(data[sl]) #self.Fit() self.Centre() self.BuildMenu(data.dtype) self.canvas = canvas self.sizer = sizer self.toolbar = toolbar self.data = data self.idxXY = idxXY self.wxAxCtrlLst = wxAxCtrlLst
def __init__(self, parent,lbl,hid): wx.Frame.__init__(self, parent, title='HDFGridView: '+lbl,size=wx.Size(750, 650)) imgDir=ut.Path.GetImage() icon = wx.Icon(os.path.join(imgDir,'h5pyViewer.ico'), wx.BITMAP_TYPE_ICO) self.SetIcon(icon) pan = wx.Panel(self, -1) t=type(hid) if t==h5py.h5d.DatasetID: data=h5py.Dataset(hid) elif t==np.ndarray: data=hid else: raise(TypeError('unhandled type')) grid = Grid(pan, data) tbl=grid.GetTable() sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(grid, 1, wx.EXPAND) wxAxCtrlLst=[] l=len(data.shape) if l==1: if type(hid.get_type())==h5py.h5t.TypeCompoundID: tbl = Table1DCompound(data) else: tbl = Table1DArray(data) else: idxXY=(l-2,l-1) #idxXY=(l-1,l-2) for idx,l in enumerate(data.shape): if idx in idxXY: continue wxAxCtrl=ut.SliderGroup(pan, label='Axis:%d'%idx,range=(0,l-1)) wxAxCtrl.idx=idx wxAxCtrlLst.append(wxAxCtrl) sizer.Add(wxAxCtrl.sizer, 0, wx.EXPAND | wx.ALIGN_CENTER | wx.ALL, border=5) wxAxCtrl.SetCallback(Grid.OnSetView,wxAxCtrl) sl=ut.GetSlice(idxXY,data.shape,wxAxCtrlLst) if type(hid.get_type())==h5py.h5t.TypeCompoundID: tbl = Table2DArray(data) else: tbl = Table2DArray(data) tbl.idxXY=idxXY if idxXY[0]<idxXY[1]: tbl.view = tbl.data[sl] else: tbl.view = tbl.data[sl].T self.wxAxCtrlLst=wxAxCtrlLst #print type(tbl) grid.SetTable (tbl, True) #AutoSize must be called after SetTable, but takes lot of time on big tables! if tbl.GetNumberCols()*tbl.GetNumberRows()<50*50: grid.AutoSizeColumns(True);grid.AutoSizeRows(True) #grid.SetDefaultColSize(200, True) self.grid=grid pan.SetSizer(sizer) pan.Layout() self.Centre() self.BuildMenu() grid.Bind(wx.grid.EVT_GRID_CMD_COL_SIZE, self.OnColSize)
def __init__(self, parent, lbl, hid): wx.Frame.__init__(self, parent, title=lbl, size=wx.Size(850, 650)) t = type(hid) if t == h5py.h5d.DatasetID: data = h5py.Dataset(hid) self.data = data self.idxXY = (data.ndim - 2, data.ndim - 1) self.slice_idx = [ 0, ] * data.ndim imgDir = ut.Path.GetImage() icon = wx.Icon(os.path.join(imgDir, 'h5pyViewer.ico'), wx.BITMAP_TYPE_ICO) self.SetIcon(icon) canvas = MPLCanvasImg(self, self.SetStatusCB) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(canvas, 1, wx.LEFT | wx.TOP | wx.EXPAND) self.SetSizer(sizer) toolbar = ut.AddToolbar(canvas, sizer) xy_sel_sizer = wx.BoxSizer(wx.HORIZONTAL) xy_sel_sizer.Add(wx.StaticText(self, label="X Axis:"), 0, wx.ALIGN_CENTER_VERTICAL) x_axis_combo = wx.ComboBox(self, -1, choices=tuple( str(x) for x in range(0, data.ndim)), style=wx.CB_READONLY, size=wx.Size(100, -1)) x_axis_combo.SetValue(str(self.idxXY[0])) xy_sel_sizer.Add(x_axis_combo, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, border=5) xy_sel_sizer.Add(wx.StaticText(self, label="Y Axis:"), 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, border=20) y_axis_combo = wx.ComboBox(self, -1, choices=tuple( str(x) for x in range(0, data.ndim)), style=wx.CB_READONLY, size=wx.Size(100, -1)) y_axis_combo.SetValue(str(self.idxXY[1])) xy_sel_sizer.Add(y_axis_combo, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, border=5) xy_sel_sizer.Add(wx.StaticText(self, label="Shape: %s" % (data.shape, )), 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, border=20) self.Bind(wx.EVT_COMBOBOX, self.OnSetAxes, x_axis_combo) self.Bind(wx.EVT_COMBOBOX, self.OnSetAxes, y_axis_combo) self.x_axis_combo = x_axis_combo self.y_axis_combo = y_axis_combo sizer.Add(xy_sel_sizer, 0, wx.ALIGN_LEFT | wx.EXPAND | wx.ALL, border=5) self.wxAxCtrlLst = [] for idx, l in enumerate(data.shape): if idx in self.idxXY: continue wxAxCtrl = ut.SliderGroup(self, label='', range=(0, 1)) wxAxCtrl.idx = idx self.wxAxCtrlLst.append(wxAxCtrl) sizer.Add(wxAxCtrl.sizer, 0, wx.EXPAND | wx.ALIGN_CENTER | wx.ALL, border=5) wxAxCtrl.SetCallback(HdfImageFrame.OnSetView, wxAxCtrl) self.updateSliceSliders() canvas.InitChild(self.getSliceArray()) #self.Fit() self.Centre() self.BuildMenu(data.dtype) self.canvas = canvas self.sizer = sizer self.toolbar = toolbar