コード例 #1
0
    def setSessionDetail(self, grid, session, begin_row, begin_col):
        """ Sets session detail in GUI
        
            Arguments:
            grid -- wx.grid.Grid    The grid to add session details t
            session -- model_runner_db.CalibrationSession
            begin_row -- int        The row to begin adding values to
            begin_col -- int        The column to begin adding values to
        """
        #self.sessionDetail.Clear()
        #self.sessionDetail.WriteText("id: %s\nobs_filename: %s" %
        #                             (session.id, session.obs_filename))

        grid.ClearGrid()
        
        grid.SetCellValue(begin_row, begin_col, str(session.starttime))
        if session.endtime:
            grid.SetCellValue(begin_row+1, begin_col, str(session.endtime))
        grid.SetCellValue(begin_row+2, begin_col, session.user)
        grid.SetCellValue(begin_row+3, begin_col, session.project)
        grid.SetCellValue(begin_row+4, begin_col, str(session.iterations))
        grid.SetCellValue(begin_row+5, begin_col, str(session.processes))
        grid.SetCellValue(begin_row+6, begin_col, session.status)
        if session.obs_filename:
            grid.SetCellValue(begin_row+7, begin_col, session.obs_filename)
        if session.notes:
            grid.SetCellValue(begin_row+8, begin_col, session.notes)
        grid.AutoSizeColumns()
        grid.AutoSizeRows()
コード例 #2
0
    def addSessionsToGrid(self, grid, begin_row, begin_col):
        """ Add session.id to each row of the grid

            Arguments:
            grid -- wx.grid.Grid    The grid to add session IDs to
            begin_row -- int        The row to begin adding values to
            begin_col -- int        The column to begin adding values to
            
        """
        if None == self.sessions:
            self.sessions = self.calibratorDB.getSessions()

        grid.ClearGrid()

        # Add rows to the grid if necessary
        numSessions = len(self.sessions)
        rowsNeeded = numSessions - grid.NumberRows
        if rowsNeeded > 0:
            grid.AppendRows(rowsNeeded)

        myRow = begin_row
        for session in self.sessions:
            grid.SetCellValue(myRow, begin_col, str(session.id))
            myRow += 1
        grid.AutoSizeColumns()
        grid.AutoSizeRows()
コード例 #3
0
ファイル: Testfile.py プロジェクト: harrycha/Pycation
    def __init__(self, parent, vlist=[], ntitle="Values"):
        wx.Frame.__init__(self, parent, -1, ntitle, wx.DefaultPosition,
                          wx.Size(400, 500))
        global dir_path
        self.SetMenu()
        icon_path = os.path.join(dir_path, "Icon")

        self.icon = wx.Icon(os.path.join(icon_path, "Text.ico"),
                            wx.BITMAP_TYPE_ICO)
        self.SetIcon(self.icon)

        wx.BeginBusyCursor()
        self.grid = grid = wx.Grid(self, -1)

        rtotal = len(vlist)
        try:
            ctotal = len(vlist[0])
        except:
            ctotal = 1

        grid.CreateGrid(rtotal, ctotal)

        grid.SetColLabelAlignment(wx.ALIGN_LEFT, wx.ALIGN_BOTTOM)

        row = 0
        for val in vlist:
            col = 0
            for set in val:
                grid.SetCellValue(row, col, str(set))
                col += 1
            row += 1

        grid.AutoSizeRows()
        grid.Refresh()
        wx.EndBusyCursor()
コード例 #4
0
def changeGrid(grid,
               data,
               colnames,
               rownames,
               oddcol="#f0f0f0",
               evencol="white"):
    if len(data) > 0:
        model = MinimalGridTableModel(len(data), len(data[0]), data, colnames,
                                      rownames, oddcol, evencol)
        grid.SetTable(model, True)
        grid.Refresh()
        grid.AutoSizeRows()
        grid.AutoSizeColumns()
        return grid
コード例 #5
0
    def addRunDetailsToGrid(self, grid, run, begin_row, begin_col):
        """ Sets run detail in GUI

            Arguments:
            grid -- wx.grid.Grid    The grid to add run details to
            run -- model_runner_db.CalibrationRun
            begin_row -- int        The row to begin adding values to
            begin_col -- int        The column to begin adding values to 
        """
        grid.ClearGrid()

        grid.SetCellValue(begin_row, begin_col, run.worldfile)
        grid.SetCellValue(begin_row+1, begin_col, run.output_path)
        grid.SetCellValue(begin_row+2, begin_col, run.cmd_raw)
        if run.param_s1:
            grid.SetCellValue(begin_row+3, begin_col, "%.4f" % run.param_s1)
        if run.param_s2:
            grid.SetCellValue(begin_row+4, begin_col, "%.4f" % run.param_s2)
        if run.param_s3:
            grid.SetCellValue(begin_row+5, begin_col, "%.4f" % run.param_s3)
        if run.param_sv1:
            grid.SetCellValue(begin_row+6, begin_col, "%.4f" % run.param_sv1)
        if run.param_sv2:
            grid.SetCellValue(begin_row+7, begin_col, "%.4f" % run.param_sv2)
        if run.param_gw1:
            grid.SetCellValue(begin_row+8, begin_col, "%.4f" % run.param_gw1)
        if run.param_gw2:
            grid.SetCellValue(begin_row+9, begin_col, "%.4f" % run.param_gw2)
        if run.param_vgsen1:
            grid.SetCellValue(begin_row+10, begin_col, 
                              "%.4f" % run.param_vgsen1)
        if run.param_vgsen2:
            grid.SetCellValue(begin_row+11, begin_col, 
                              "%.4f" % run.param_vgsen2)
        if run.param_vgsen3:
            grid.SetCellValue(begin_row+12, begin_col, 
                              "%.4f" % run.param_vgsen3)
        grid.AutoSizeColumns()
        grid.AutoSizeRows()
コード例 #6
0
ファイル: hdfGrid.py プロジェクト: warlock8hz/h5pyViewer
  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)