コード例 #1
0
    def CreationLigne(self):
        """ Création d'une ligne """
        numLigne = self.GetNumberRows()-1
##        if numLigne > 24 :
##            dlg = wx.MessageDialog(self, _(u"Vous ne pouvez saisir qu'un maximum de 26 lignes !"), "Erreur", wx.OK | wx.ICON_EXCLAMATION)
##            dlg.ShowModal()
##            dlg.Destroy()
##            return
        # Création de la ligne
        self.AppendRows(1)
        numLigne += 1
        self.SetRowLabelValue(numLigne, str(numLigne+1)) #self.SetRowLabelValue(numLigne, ALPHABET[numLigne])
        self.SetRowSize(numLigne, 20)
        # Mémorisation de la ligne
        if self.dictDonnees.has_key(self.code) == False : 
            self.dictDonnees[self.code] = {}
        if self.dictDonnees[self.code].has_key(numLigne) == False : 
            self.dictDonnees[self.code][numLigne] = {}
        # Configuration des cases
        numColonne = 0
        for indexColonne in self.listeColonnes :
            codeEditeur = LISTE_COLONNES[indexColonne]["editeur"]
            if codeEditeur == "decimal" :
                renderer = gridlib.GridCellFloatRenderer(6, 2)
                editor = gridlib.GridCellFloatEditor(6, 2)
            elif codeEditeur == "decimal3" :
                renderer = gridlib.GridCellFloatRenderer(6, 3)
                editor = gridlib.GridCellFloatEditor(6, 3)
            elif codeEditeur == "decimal4" :
                renderer = gridlib.GridCellFloatRenderer(6, 4)
                editor = gridlib.GridCellFloatEditor(6, 4)
            elif codeEditeur == "decimal6" :
                renderer = gridlib.GridCellFloatRenderer(6, 6)
                editor = gridlib.GridCellFloatEditor(6, 6)
            elif codeEditeur == "entier" :
                renderer = gridlib.GridCellNumberRenderer()
                editor = gridlib.GridCellNumberEditor(0, 100)
            elif codeEditeur == "heure" :
                renderer = None
                editor = EditeurHeure()
            elif codeEditeur == "date" :
                renderer = None
                editor = EditeurDate()
            elif codeEditeur == "questionnaire" :
                listeChoix = [(0, ""),]
                for dictQuestion in self.listeQuestions :
                    if dictQuestion["controle"] in ("montant", "decimal") :
                        label = dictQuestion["label"] + " (%s)" % dictQuestion["type"].capitalize()
                        listeChoix.append((dictQuestion["IDquestion"], label))
                renderer = RendererChoix(listeChoix)
                editor = EditeurChoix(listeChoix)
            else:
                renderer = None
                editor = None
            if renderer != None : self.SetCellRenderer(numLigne, numColonne, renderer)
            if editor != None : self.SetCellEditor(numLigne, numColonne, editor)
            
            self.SetCellBackgroundColour(numLigne, numColonne, COULEUR_FOND_CASE)
            
            numColonne += 1
コード例 #2
0
    def __set_dev_grid(self):
        colourBackground = self.gridDev.GetLabelBackgroundColour()
        attributes = grid.GridCellAttr()
        attributes.SetBackgroundColour(colourBackground)
        self.gridDev.SetColAttr(self.COL_IND, attributes)

        self.gridDev.ClearGrid()

        i = 0
        for device in self.devices:
            self.gridDev.SetReadOnly(i, self.COL_SEL, True)
            self.gridDev.SetReadOnly(i, self.COL_DEV, device.isDevice)
            self.gridDev.SetReadOnly(i, self.COL_TUN, True)
            self.gridDev.SetReadOnly(i, self.COL_SER, True)
            self.gridDev.SetReadOnly(i, self.COL_IND, True)
            self.gridDev.SetCellRenderer(i, self.COL_SEL,
                                         TickCellRenderer())
            if device.isDevice:
                cell = grid.GridCellChoiceEditor(map(str, device.gains),
                                                 allowOthers=False)
                self.gridDev.SetCellEditor(i, self.COL_GAIN, cell)
            self.gridDev.SetCellEditor(i, self.COL_CAL,
                                       grid.GridCellFloatEditor(-1, 3))
            self.gridDev.SetCellEditor(i, self.COL_LEVOFF,
                                       grid.GridCellFloatEditor(-1, 3))
            self.gridDev.SetCellEditor(i, self.COL_LO,
                                       grid.GridCellFloatEditor(-1, 3))
            if device.isDevice:
                self.gridDev.SetCellValue(i, self.COL_DEV, device.name)
                self.gridDev.SetCellValue(i, self.COL_SER, str(device.serial))
                self.gridDev.SetCellValue(i, self.COL_IND, str(i))
                self.gridDev.SetCellBackgroundColour(i, self.COL_DEV,
                                                     colourBackground)
                self.gridDev.SetCellValue(i, self.COL_GAIN,
                                          str(nearest(device.gain,
                                                      device.gains)))
            else:
                self.gridDev.SetCellValue(i, self.COL_DEV,
                                          '{}:{}'.format(device.server,
                                                         device.port))
                self.gridDev.SetCellValue(i, self.COL_SER, '')
                self.gridDev.SetCellValue(i, self.COL_IND, '')
                self.gridDev.SetCellValue(i, self.COL_GAIN, str(device.gain))
            self.gridDev.SetCellBackgroundColour(i, self.COL_SER,
                                                 colourBackground)

            self.gridDev.SetCellValue(i, self.COL_TUN, TUNER[device.tuner])
            self.gridDev.SetCellValue(i, self.COL_CAL, str(device.calibration))
            self.gridDev.SetCellValue(i, self.COL_LEVOFF, str(device.levelOff))
            self.gridDev.SetCellValue(i, self.COL_LO, str(device.lo))
            self.gridDev.SetCellValue(i, self.COL_OFF, str(device.offset / 1e3))
            i += 1

        if self.settings.indexRtl >= len(self.devices):
            self.settings.indexRtl = len(self.devices) - 1
        self.__select_row(self.settings.indexRtl)
        self.index = self.settings.indexRtl

        self.gridDev.AutoSize()
コード例 #3
0
    def update_table(self):
        self.busy_cursor = wx.BusyCursor()
        if self.tags_grid.GetNumberRows():  # wx таблица не пуста
            self.tags_grid.DeleteRows(pos=0,
                                      numRows=self.tags_grid.GetNumberRows())
        else:  # таблица пуста - удалять нечего
            pass
        self.label_start_time.SetLabelText(str(self.DATA.time_start))
        self.label_stop_time.SetLabelText(str(self.DATA.time_stop))
        G = self.tags_grid
        for idx, tag in enumerate(self.DATA.tags_list):
            G.AppendRows(numRows=1)
            G.SetCellValue(idx, TAG_column, tag)
            G.AutoSizeColumn(TAG_column)

            G.SetCellEditor(idx, MINVALUE_column,
                            gridlib.GridCellFloatEditor())
            G.SetCellValue(idx, MINVALUE_column,
                           '%.7f' % self.DATA.tag_min(tag))
            G.SetCellAlignment(idx, MINVALUE_column, wx.ALIGN_RIGHT,
                               wx.ALIGN_CENTER)
            G.AutoSizeColumn(MINVALUE_column)

            G.SetCellEditor(idx, MAXVALUE_column,
                            gridlib.GridCellFloatEditor())
            G.SetCellValue(idx, MAXVALUE_column,
                           '%.7f' % self.DATA.tag_max(tag))
            G.SetCellAlignment(idx, MAXVALUE_column, wx.ALIGN_RIGHT,
                               wx.ALIGN_CENTER)
            G.AutoSizeColumn(MAXVALUE_column)
        # update buttons
        if self.DATA.tags_list:  # не пустой список тэгов
            self.bitmap_button_fillna.Enable(True)
            self.bitmap_button_save.Enable(True)
            self.choice_derivative.Enable(True)
            self.bitmap_button_downsample.Enable(True)
            if self.DATA.data.size < 300000:
                self.bitmap_button_2excel.Enable()
                self.bitmap_button_2excel.SetToolTip(_("Export to excel"))
            else:
                self.bitmap_button_2excel.SetToolTip("Too much data! %i" %
                                                     self.DATA.data.size)
                self.bitmap_button_2excel.Enable(False)
        else:  # пустой список тегов
            self.bitmap_button_downsample.Enable(False)
            self.bitmap_button_2excel.Enable(False)
            self.bitmap_button_save.Enable(False)
            self.on_clear_selection_btn(None)
            self.choice_derivative.Enable(False)

        self.Layout()
        self.busy_cursor = None
コード例 #4
0
ファイル: panels.py プロジェクト: zhaojiahai/RTLSDR-Scanner
 def __set_freq_editor(self):
     for (row, col) in self.locsFreq:
         self.grid.SetReadOnly(row, col, False)
         self.grid.SetCellAlignment(row, col, wx.ALIGN_RIGHT,
                                    wx.ALIGN_CENTRE)
         self.grid.SetCellEditor(row, col,
                                 wxGrid.GridCellFloatEditor(precision=4))
コード例 #5
0
ファイル: control2.py プロジェクト: pratikaher88/SenselWork
    def __init__(self):
        """Constructor"""
        wx.Frame.__init__(self,
                          parent=None,
                          title="Grid Tutorial Two",
                          size=(800, 600))
        panel = wx.Panel(self)
        myGrid = gridlib.Grid(panel)
        myGrid.CreateGrid(20, 8)

        myGrid.SetCellValue(0, 0, "Hello")
        print(myGrid.GetCellValue(0, 0))

        myGrid.GetCellEditor(4, 5)
        # for i in range(5):
        #     print(i)
        #     myGrid.SelectBlock(4,i,4,i)

        # myGrid.SelectBlock(1,1,1,1)

        myGrid.SetCellValue(1, 1, "I'm in red!")
        myGrid.SetCellTextColour(1, 1, wx.RED)

        myGrid.SetCellEditor(5, 0, gridlib.GridCellNumberEditor(1, 1000))
        myGrid.SetCellValue(5, 0, "123")

        myGrid.SetCellEditor(6, 0, gridlib.GridCellFloatEditor())
        myGrid.SetCellValue(6, 0, "123.34")
        myGrid.SetCellEditor(7, 0, gridlib.GridCellNumberEditor())

        # self.Bind(gridlib.EVT_GRID_SELECT_CELL, self.OnSelectCell)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(myGrid)
        panel.SetSizer(sizer)
コード例 #6
0
ファイル: TTResults.py プロジェクト: pythonthings/SprintMgr
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)

        self.headerNames = ['Pos', 'Bib', 'Name', 'Team', 'Time']

        self.grid = ReorderableGrid(self, style=wx.BORDER_SUNKEN)
        self.grid.DisableDragRowSize()
        self.grid.SetRowLabelSize(0)
        self.grid.CreateGrid(0, len(self.headerNames))
        self.setColNames()
        self.grid.EnableReorderRows(False)

        # Set a larger font for the table.
        # Set specialized editors for appropriate columns.
        font = GetFont()
        self.grid.SetLabelFont(font)
        for col in six.moves.range(self.grid.GetNumberCols()):
            attr = gridlib.GridCellAttr()
            attr.SetFont(font)
            if col == self.grid.GetNumberCols() - 1:
                attr.SetRenderer(gridlib.GridCellFloatRenderer(-1, 3))
                attr.SetEditor(gridlib.GridCellFloatEditor(-1, 3))
            else:
                if col in (0, 1):
                    attr.SetRenderer(gridlib.GridCellNumberRenderer())
                attr.SetReadOnly(True)
            self.grid.SetColAttr(col, attr)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.grid, 1, flag=wx.EXPAND | wx.ALL, border=6)
        self.SetSizer(sizer)
コード例 #7
0
ファイル: MonitorCenter.py プロジェクト: yvs/psychopy
    def __init__(self, parent, id=-1, rows=[], cols=[], data=None):
        self.moveTo = None
        self.nRows, self.nCols = len(rows), len(cols)
        grid.Grid.__init__(self, parent, -1,
                           wx.Point(0, 0))  #,wx.Size( 300, 150 ))

        self.numEditor = grid.GridCellFloatEditor()
        self.CreateGrid(self.nRows, self.nCols)
        for nCol, col in enumerate(cols):
            self.SetColLabelValue(nCol, col)
            self.SetColFormatFloat(nCol, 4, 4)
            #self.SetColMinimalWidth(nCol,800)
        for nRow, row in enumerate(rows):
            self.SetRowLabelValue(nRow, row)
        for nRow in range(self.nRows):
            for nCol in range(self.nCols):
                self.SetCellEditor(nRow, nCol, self.numEditor)
        self.setData(data)
        #self.SetMargins(-5,-5)
        wx.EVT_IDLE(self, self.OnIdle)
コード例 #8
0
 def __init__(self, parent):
     Grid.Grid.__init__(self, parent, -1)
     self.CreateGrid(25, 4)
     self._rows = 25
     self._cols = 4
     self.SetColLabelValue(0, _("Location"))
     self.SetColLabelValue(1, _("Intensity"))
     self.SetColLabelValue(2, _("Comment"))
     self.SetColLabelValue(3, _("Frozen"))
     attr = Grid.GridCellAttr()
     attrb = Grid.GridCellAttr()
     attr.SetEditor(Grid.GridCellFloatEditor())
     attrb.SetEditor(Grid.GridCellBoolEditor())
     attrb.SetRenderer(Grid.GridCellBoolRenderer())
     self.SetColAttr(0, attr)
     self.SetColAttr(1, attr)
     self.SetColSize(2, self.GetColSize(2) * 4)
     self.SetColAttr(3, attrb)
     self.Bind(Grid.EVT_GRID_LABEL_RIGHT_CLICK, self.OnLabelRightClicked)
     self.Bind(Grid.EVT_GRID_CELL_CHANGE, self.OnCellChange)
     wx.EVT_KEY_DOWN(self, self.on_key)
コード例 #9
0
ファイル: grid_cell.py プロジェクト: ipandage/language_study
    def __init__(self, parent):
        grid.Grid.__init__(self, parent, -1)
        self.CreateGrid(8, 4)
        self.EnableEditing(True)

        self.SetColLabelValue(0, u"第1列")  # 设置行标题
        self.SetColLabelAlignment(wx.ALIGN_LEFT, wx.ALIGN_BOTTOM)
        self.SetRowLabelValue(0, u"第1行")  # 设置列标题
        self.SetRowLabelAlignment(wx.ALIGN_RIGHT, wx.ALIGN_BOTTOM)

        self.SetCellValue(0, 0, "Hello")
        self.SetCellTextColour(0, 0, wx.RED)
        self.SetCellFont(0, 0, wx.Font(10, wx.ROMAN, wx.ITALIC,
                                       wx.NORMAL))  # 设置单元格的字体

        self.SetCellValue(1, 0, "Read Only")
        self.SetReadOnly(1, 0, True)  # 设置只读单元格
        self.SetCellBackgroundColour(1, 0, wx.RED)  # 设置单元格的背景颜色

        self.SetCellEditor(2, 0, grid.GridCellNumberEditor(1, 10))  # 嵌入数字选择控件
        self.SetCellValue(2, 0, "1")
        self.SetCellEditor(2, 1, grid.GridCellFloatEditor(0, 1))  # 嵌入浮点数编辑控件
        self.SetCellValue(2, 1, "10.19")

        attr = grid.GridCellAttr()
        attr.SetTextColour(wx.BLUE)
        self.SetColAttr(1, attr)  # 设置一列的单元格属性

        self.SetCellAlignment(5, 1, wx.ALIGN_CENTRE, wx.ALIGN_BOTTOM)
        self.SetCellValue(5, 1, u"跨行、列的单元格")
        self.SetCellSize(5, 1, 2, 2)  # 设置跨行、列的单元格

        self.SetCellEditor(6, 0,
                           grid.GridCellChoiceEditor(["one", "two",
                                                      "three"]))  # 嵌入下拉列表
        self.SetCellValue(6, 0, "one")

        self.SetCellEditor(7, 0, grid.GridCellBoolEditor())  # 嵌入下拉列表
        self.SetCellValue(7, 0, "True")
コード例 #10
0
ファイル: grid_test.py プロジェクト: hchocholacs/jumegX
    def __init__(self):
        """Constructor"""
        wx.Frame.__init__(self,
                          parent=None,
                          title="Grid Tutorial Two",
                          size=(650, 320))
        panel = wx.Panel(self)

        myGrid = gridlib.Grid(panel)
        myGrid.CreateGrid(15, 6)

        myGrid.SetCellValue(0, 0, "Hello")
        myGrid.SetCellFont(0, 0, wx.Font(12, wx.ROMAN, wx.ITALIC, wx.NORMAL))
        print myGrid.GetCellValue(0, 0)

        myGrid.SetCellValue(1, 1, "I'm in red!")
        myGrid.SetCellTextColour(1, 1, wx.RED)

        myGrid.SetCellBackgroundColour(2, 2, wx.CYAN)

        myGrid.SetCellValue(3, 3, "This cell is read-only")
        myGrid.SetReadOnly(3, 3, True)

        myGrid.SetCellEditor(5, 0, gridlib.GridCellNumberEditor(1, 1000))
        myGrid.SetCellValue(5, 0, "123")
        myGrid.SetCellEditor(6, 0, gridlib.GridCellFloatEditor())
        myGrid.SetCellValue(6, 0, "123.34")
        myGrid.SetCellEditor(7, 0, gridlib.GridCellNumberEditor())

        myGrid.SetCellSize(11, 1, 3, 3)
        myGrid.SetCellAlignment(11, 1, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
        myGrid.SetCellValue(11, 1,
                            "This cell is set to span 3 rows and 3 columns")

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(myGrid)
        panel.SetSizer(sizer)
コード例 #11
0
    def __init__(self, parent, log):
        gridlib.Grid.__init__(self, parent, -1)
        ##mixins.GridAutoEditMixin.__init__(self)
        self.log = log
        self.moveTo = None

        self.Bind(wx.EVT_IDLE, self.OnIdle)

        self.CreateGrid(25, 25)#, gridlib.Grid.SelectRows)
        ##self.EnableEditing(False)

        # simple cell formatting
        self.SetColSize(3, 200)
        self.SetRowSize(4, 45)
        self.SetCellValue(0, 0, "First cell")
        self.SetCellValue(1, 1, "Another cell")
        self.SetCellValue(2, 2, "Yet another cell")
        self.SetCellValue(3, 3, "This cell is read-only")
        self.SetCellFont(0, 0, wx.Font(12, wx.ROMAN, wx.ITALIC, wx.NORMAL))
        self.SetCellTextColour(1, 1, wx.RED)
        self.SetCellBackgroundColour(2, 2, wx.CYAN)
        self.SetReadOnly(3, 3, True)

        self.SetCellEditor(5, 0, gridlib.GridCellNumberEditor(1,1000))
        self.SetCellValue(5, 0, "123")
        self.SetCellEditor(6, 0, gridlib.GridCellFloatEditor())
        self.SetCellValue(6, 0, "123.34")
        self.SetCellEditor(7, 0, gridlib.GridCellNumberEditor())

        self.SetCellValue(6, 3, "You can veto editing this cell")

        #self.SetRowLabelSize(0)
        #self.SetColLabelSize(0)

        # attribute objects let you keep a set of formatting values
        # in one spot, and reuse them if needed
        attr = gridlib.GridCellAttr()
        attr.SetTextColour(wx.BLACK)
        attr.SetBackgroundColour(wx.RED)
        attr.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD))

        # you can set cell attributes for the whole row (or column)
        self.SetRowAttr(5, attr)

        self.SetColLabelValue(0, "Custom")
        self.SetColLabelValue(1, "column")
        self.SetColLabelValue(2, "labels")

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

        #self.SetDefaultCellOverflow(False)
        #r = gridlib.GridCellAutoWrapStringRenderer()
        #self.SetCellRenderer(9, 1, r)

        # overflow cells
        self.SetCellValue( 9, 1, "This default cell will overflow into neighboring cells, but not if you turn overflow off.");
        self.SetCellSize(11, 1, 3, 3);
        self.SetCellAlignment(11, 1, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE);
        self.SetCellValue(11, 1, "This cell is set to span 3 rows and 3 columns");


        editor = gridlib.GridCellTextEditor()
        editor.SetParameters('10')
        self.SetCellEditor(0, 4, editor)
        self.SetCellValue(0, 4, "Limited text")

        renderer = gridlib.GridCellAutoWrapStringRenderer()
        self.SetCellRenderer(15,0, renderer)
        self.SetCellValue(15,0, "The text in this cell will be rendered with word-wrapping")

        
        # test all the events
        self.Bind(gridlib.EVT_GRID_CELL_LEFT_CLICK, self.OnCellLeftClick)
        self.Bind(gridlib.EVT_GRID_CELL_RIGHT_CLICK, self.OnCellRightClick)
        self.Bind(gridlib.EVT_GRID_CELL_LEFT_DCLICK, self.OnCellLeftDClick)
        self.Bind(gridlib.EVT_GRID_CELL_RIGHT_DCLICK, self.OnCellRightDClick)

        self.Bind(gridlib.EVT_GRID_LABEL_LEFT_CLICK, self.OnLabelLeftClick)
        self.Bind(gridlib.EVT_GRID_LABEL_RIGHT_CLICK, self.OnLabelRightClick)
        self.Bind(gridlib.EVT_GRID_LABEL_LEFT_DCLICK, self.OnLabelLeftDClick)
        self.Bind(gridlib.EVT_GRID_LABEL_RIGHT_DCLICK, self.OnLabelRightDClick)

        self.Bind(gridlib.EVT_GRID_ROW_SIZE, self.OnRowSize)
        self.Bind(gridlib.EVT_GRID_COL_SIZE, self.OnColSize)

        self.Bind(gridlib.EVT_GRID_RANGE_SELECT, self.OnRangeSelect)
        self.Bind(gridlib.EVT_GRID_CELL_CHANGE, self.OnCellChange)
        self.Bind(gridlib.EVT_GRID_SELECT_CELL, self.OnSelectCell)

        self.Bind(gridlib.EVT_GRID_EDITOR_SHOWN, self.OnEditorShown)
        self.Bind(gridlib.EVT_GRID_EDITOR_HIDDEN, self.OnEditorHidden)
        self.Bind(gridlib.EVT_GRID_EDITOR_CREATED, self.OnEditorCreated)
コード例 #12
0
    def on_initialize(self, event):
        self.log = sys.stdout
        self.moveTo = None

        ##        wx.EVT_IDLE(self, self.OnIdle)

        mygrid = self.components.mygrid

        mygrid.CreateGrid(25, 25)  #, wxGrid.wxGridSelectRows)
        ##mygrid.EnableEditing(False)

        # simple cell formatting
        mygrid.SetColSize(3, 200)
        mygrid.SetRowSize(4, 45)
        mygrid.SetCellValue(0, 0, "First cell")
        mygrid.SetCellValue(1, 1, "Another cell")
        mygrid.SetCellValue(2, 2, "Yet another cell")
        mygrid.SetCellValue(3, 3, "This cell is read-only")
        mygrid.SetCellFont(0, 0, wx.Font(12, wx.ROMAN, wx.ITALIC, wx.NORMAL))
        mygrid.SetCellTextColour(1, 1, wx.RED)
        mygrid.SetCellBackgroundColour(2, 2, wx.CYAN)
        mygrid.SetReadOnly(3, 3, True)

        mygrid.SetCellEditor(5, 0, grid.GridCellNumberEditor(1, 1000))
        mygrid.SetCellValue(5, 0, "123")
        mygrid.SetCellEditor(6, 0, grid.GridCellFloatEditor())
        mygrid.SetCellValue(6, 0, "123.34")
        mygrid.SetCellEditor(7, 0, grid.GridCellNumberEditor())

        mygrid.SetCellValue(6, 3, "You can veto editing this cell")

        # attribute objects let you keep a set of formatting values
        # in one spot, and reuse them if needed
        attr = grid.GridCellAttr()
        attr.SetTextColour(wx.BLACK)
        attr.SetBackgroundColour(wx.RED)
        attr.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD))

        # you can set cell attributes for the whole row (or column)
        mygrid.SetRowAttr(5, attr)

        mygrid.SetColLabelValue(0, "Custom")
        mygrid.SetColLabelValue(1, "column")
        mygrid.SetColLabelValue(2, "labels")

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

        #mygrid.SetDefaultCellOverflow(False)
        #r = wx.GridCellAutoWrapStringRenderer()
        #mygrid.SetCellRenderer(9, 1, r)

        # overflow cells
        mygrid.SetCellValue(
            9, 1,
            "This default cell will overflow into neighboring cells, but not if you turn overflow off."
        )
        mygrid.SetCellSize(11, 1, 3, 3)
        mygrid.SetCellAlignment(11, 1, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
        mygrid.SetCellValue(11, 1,
                            "This cell is set to span 3 rows and 3 columns")

        sizer1 = wx.BoxSizer(wx.VERTICAL)
        sizer1.Add(self.components.mygrid, 1, wx.EXPAND)

        sizer1.Fit(self)
        sizer1.SetSizeHints(self)
        self.panel.SetSizer(sizer1)
        self.panel.SetAutoLayout(1)
        self.panel.Layout()
コード例 #13
0
    def __init__(self, parent, devices, settings):
        self.settings = settings
        self.index = 0

        wx.Dialog.__init__(self, parent=parent, title="Preferences")

        title = wx.StaticText(self, label="Select a device")
        font = title.GetFont()
        font.SetPointSize(font.GetPointSize() + 2)
        title.SetFont(font)

        self.devices = devices
        self.gridDev = grid.Grid(self)
        self.gridDev.CreateGrid(len(self.devices), 6)
        self.gridDev.SetRowLabelSize(0)
        self.gridDev.SetColLabelValue(0, "Select")
        self.gridDev.SetColLabelValue(1, "Device")
        self.gridDev.SetColLabelValue(2, "Index")
        self.gridDev.SetColLabelValue(3, "Calibration\n(ppm)")
        self.gridDev.SetColLabelValue(4, "LO\n(MHz)")
        self.gridDev.SetColLabelValue(5, "Band Offset\n(kHz)")
        self.gridDev.SetColFormatFloat(3, -1, 3)
        self.gridDev.SetColFormatFloat(4, -1, 3)
        self.gridDev.SetColFormatFloat(5, -1, 0)

        attributes = grid.GridCellAttr()
        attributes.SetBackgroundColour(self.gridDev.GetLabelBackgroundColour())
        self.gridDev.SetColAttr(1, attributes)
        self.gridDev.SetColAttr(2, attributes)

        i = 0
        for device in self.devices:
            self.gridDev.SetReadOnly(i, 0, True)
            self.gridDev.SetReadOnly(i, 1, True)
            self.gridDev.SetReadOnly(i, 2, True)
            self.gridDev.SetCellRenderer(i, 0, CellRenderer())
            self.gridDev.SetCellEditor(i, 3, grid.GridCellFloatEditor(-1, 3))
            self.gridDev.SetCellEditor(i, 4, grid.GridCellFloatEditor(-1, 3))
            self.gridDev.SetCellValue(i, 1, device.name)
            self.gridDev.SetCellValue(i, 2, str(i))
            self.gridDev.SetCellValue(i, 3, str(device.calibration))
            self.gridDev.SetCellValue(i, 4, str(device.lo))
            self.gridDev.SetCellValue(i, 5, str(device.offset / 1e3))
            i += 1

        if settings.index > len(self.devices):
            settings.index = len(self.devices)
        self.select_row(settings.index)

        self.gridDev.AutoSize()

        self.Bind(grid.EVT_GRID_CELL_LEFT_CLICK, self.on_click)

        sizerButtons = wx.StdDialogButtonSizer()
        buttonOk = wx.Button(self, wx.ID_OK)
        buttonCancel = wx.Button(self, wx.ID_CANCEL)
        sizerButtons.AddButton(buttonOk)
        sizerButtons.AddButton(buttonCancel)
        sizerButtons.Realize()
        self.Bind(wx.EVT_BUTTON, self.on_ok, buttonOk)

        vbox = wx.BoxSizer(wx.VERTICAL)
        vbox.Add(title, 0, wx.ALL | wx.EXPAND, 10)
        vbox.Add(self.gridDev, 0, wx.ALL | wx.EXPAND, 10)
        vbox.Add(sizerButtons, 0, wx.ALL | wx.EXPAND, 10)

        self.SetSizerAndFit(vbox)
コード例 #14
0
ファイル: excel_wx.py プロジェクト: fanyingjie2/python-code
    def __init__(self, parent, log):
        gridlib.Grid.__init__(self, parent, -1)
        ##mixins.GridAutoEditMixin.__init__(self)
        #打印log信息
        self.log = log
        self.moveTo = None

        self.Bind(wx.EVT_IDLE, self.OnIdle)
        #创建一个25X25的电子表格
        self.CreateGrid(25, 25)  #, gridlib.Grid.SelectRows)
        ##self.EnableEditing(False)

        #simple cell formatting
        #设置第index=3列的宽度大小,像素=200
        self.SetColSize(col=3, width=200)
        #设置第index=4行的高度大小,像素=45
        self.SetRowSize(4, 45)
        #设置 row=0,col=0,value="First cell"
        self.SetCellValue(0, 0, "First cell")
        #设置 row=1,col=1,value="Another cell"
        self.SetCellValue(1, 1, "Another cell")
        #设置 row=2,col=2,value="Yet another cell"
        self.SetCellValue(2, 2, "Yet another cell")
        #设置 row=3,col=3,value="This cell is read-only"
        self.SetCellValue(3, 3, "This cell is read-only")
        #设置字体格式
        self.SetCellFont(
            0, 0,
            wx.Font(12, wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_ITALIC,
                    wx.FONTWEIGHT_NORMAL))
        #设置字体颜色
        self.SetCellTextColour(1, 1, wx.RED)
        #设置cell背景颜色
        self.SetCellBackgroundColour(2, 2, wx.CYAN)
        #设置只读属性
        self.SetReadOnly(3, 3, True)
        #设置 row=5,col=0,数字编辑器
        self.SetCellEditor(5, 0, gridlib.GridCellNumberEditor(1, 1000))
        #设置 row=5,col=0,value="123"
        self.SetCellValue(5, 0, "123")
        #设置 row=6,col=0,浮点数
        self.SetCellEditor(6, 0, gridlib.GridCellFloatEditor())
        #设置 row=6,col=0,value="123.34"
        self.SetCellValue(6, 0, "123.34")
        #设置
        self.SetCellEditor(7, 0, gridlib.GridCellNumberEditor())
        #设置 row=6,col=3,value="You can veto editing this cell"
        self.SetCellValue(6, 3, "You can veto editing this cell")

        #self.SetRowLabelSize(0)
        #self.SetColLabelSize(0)

        # attribute objects let you keep a set of formatting values
        # in one spot, and reuse them if needed
        #wx.grid.GridCellAttr

        #这个类可以用来通过改变它们的默认属性来改变网格在网格中的外观。
        attr = gridlib.GridCellAttr()
        #字体颜色:黑色
        attr.SetTextColour(wx.BLACK)
        #设置背景颜色:红色
        attr.SetBackgroundColour(wx.RED)
        #设置字体格式
        attr.SetFont(
            wx.Font(10, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL,
                    wx.FONTWEIGHT_BOLD))

        # you can set cell attributes for the whole row (or column)
        #设置Row=5,attr
        self.SetRowAttr(5, attr)

        #设置Col=0,LableValue =Custom
        self.SetColLabelValue(0, "Custom")
        self.SetRowLabelValue(0, "日期")

        #设置Col=1,LabelValue = "column"
        self.SetColLabelValue(1, "column")
        #设置Col=2,LabelValue = labels
        self.SetColLabelValue(2, "labels")
        #设置列表标签左右以及上下对齐方式:左对齐,下沉
        self.SetColLabelAlignment(wx.ALIGN_LEFT, wx.ALIGN_BOTTOM)

        #self.SetDefaultCellOverflow(False)
        #r = gridlib.GridCellAutoWrapStringRenderer()
        #self.SetCellRenderer(9, 1, r)

        #overflow cells
        self.SetCellValue(
            9, 1,
            "This default cell will overflow into neighboring cells, but not if you turn overflow off."
        )
        #单元格合并处理:3x3
        self.SetCellSize(11, 1, 3, 3)
        #设置单元格对齐方式:中间,中间
        self.SetCellAlignment(11, 1, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
        #设置单元格值
        self.SetCellValue(11, 1,
                          "This cell is set to span 3 rows and 3 columns")

        #设置
        editor = gridlib.GridCellTextEditor()
        #值长度
        editor.SetParameters('10')
        #设置格式
        self.SetCellEditor(0, 4, editor)
        #设置值
        self.SetCellValue(0, 4, "Limited text")

        #可以用来格式化单元格中的字符串数据。
        renderer = gridlib.GridCellAutoWrapStringRenderer()
        self.SetCellRenderer(15, 0, renderer)
        self.SetCellValue(
            15, 0, "The text in this cell will be rendered with word-wrapping")

        # test all the events
        #左单击
        self.Bind(gridlib.EVT_GRID_CELL_LEFT_CLICK, self.OnCellLeftClick)
        #右单击
        self.Bind(gridlib.EVT_GRID_CELL_RIGHT_CLICK, self.OnCellRightClick)
        #左双击
        self.Bind(gridlib.EVT_GRID_CELL_LEFT_DCLICK, self.OnCellLeftDClick)
        #右双击
        self.Bind(gridlib.EVT_GRID_CELL_RIGHT_DCLICK, self.OnCellRightDClick)

        #label 左单击
        self.Bind(gridlib.EVT_GRID_LABEL_LEFT_CLICK, self.OnLabelLeftClick)
        #label 右单击
        self.Bind(gridlib.EVT_GRID_LABEL_RIGHT_CLICK, self.OnLabelRightClick)
        #label 左双击
        self.Bind(gridlib.EVT_GRID_LABEL_LEFT_DCLICK, self.OnLabelLeftDClick)
        #label 右双击
        self.Bind(gridlib.EVT_GRID_LABEL_RIGHT_DCLICK, self.OnLabelRightDClick)

        self.Bind(gridlib.EVT_GRID_COL_SORT, self.OnGridColSort)

        #拖动Row大小
        self.Bind(gridlib.EVT_GRID_ROW_SIZE, self.OnRowSize)
        #拖动Col大小
        self.Bind(gridlib.EVT_GRID_COL_SIZE, self.OnColSize)

        self.Bind(gridlib.EVT_GRID_RANGE_SELECT, self.OnRangeSelect)
        self.Bind(gridlib.EVT_GRID_CELL_CHANGED, self.OnCellChange)
        self.Bind(gridlib.EVT_GRID_SELECT_CELL, self.OnSelectCell)

        self.Bind(gridlib.EVT_GRID_EDITOR_SHOWN, self.OnEditorShown)
        self.Bind(gridlib.EVT_GRID_EDITOR_HIDDEN, self.OnEditorHidden)
        self.Bind(gridlib.EVT_GRID_EDITOR_CREATED, self.OnEditorCreated)
コード例 #15
0
 def editor(self):
     return gridlib.GridCellFloatEditor(*self.args)
コード例 #16
0
ファイル: Categories.py プロジェクト: johndowen/CrossMgr
    def __init__(self, parent, id=wx.ID_ANY):
        wx.Panel.__init__(self, parent, id)

        self.state = RaceInputState()

        vs = wx.BoxSizer(wx.VERTICAL)

        self.ignoreColour = wx.Colour(80, 80, 80)
        self.inactiveColour = wx.Colour(200, 200, 200)

        border = 4
        flag = wx.ALL

        hs = wx.BoxSizer(wx.HORIZONTAL)

        self.activateAllButton = wx.Button(self,
                                           label=_('Activate All'),
                                           style=wx.BU_EXACTFIT)
        self.Bind(wx.EVT_BUTTON, self.onActivateAll, self.activateAllButton)
        hs.Add(self.activateAllButton, 0, border=border, flag=flag)

        hs.AddSpacer(6)

        self.newCategoryButton = wx.Button(self,
                                           label=_('New'),
                                           style=wx.BU_EXACTFIT)
        self.Bind(wx.EVT_BUTTON, self.onNewCategory, self.newCategoryButton)
        hs.Add(self.newCategoryButton, 0, border=border, flag=flag)

        self.delCategoryButton = wx.Button(self,
                                           label=_('Delete'),
                                           style=wx.BU_EXACTFIT)
        self.Bind(wx.EVT_BUTTON, self.onDelCategory, self.delCategoryButton)
        hs.Add(self.delCategoryButton,
               0,
               border=border,
               flag=(flag & ~wx.LEFT))

        hs.AddSpacer(6)

        self.upCategoryButton = wx.Button(self,
                                          label=u'\u2191',
                                          style=wx.BU_EXACTFIT)
        self.Bind(wx.EVT_BUTTON, self.onUpCategory, self.upCategoryButton)
        hs.Add(self.upCategoryButton, 0, border=border, flag=flag)

        self.downCategoryButton = wx.Button(self,
                                            label=u'\u2193',
                                            style=wx.BU_EXACTFIT)
        self.Bind(wx.EVT_BUTTON, self.onDownCategory, self.downCategoryButton)
        hs.Add(self.downCategoryButton,
               0,
               border=border,
               flag=(flag & ~wx.LEFT))

        hs.AddSpacer(6)

        self.setGpxDistanceButton = wx.Button(self,
                                              label=_('Set Gpx Distance'),
                                              style=wx.BU_EXACTFIT)
        self.Bind(wx.EVT_BUTTON, self.onSetGpxDistance,
                  self.setGpxDistanceButton)
        hs.Add(self.setGpxDistanceButton, 0, border=border, flag=flag)

        hs.AddSpacer(6)

        self.addExceptionsButton = wx.Button(self,
                                             label=_('Bib Exceptions'),
                                             style=wx.BU_EXACTFIT)
        self.Bind(wx.EVT_BUTTON, self.onAddExceptions,
                  self.addExceptionsButton)
        hs.Add(self.addExceptionsButton, 0, border=border, flag=flag)

        hs.AddSpacer(6)
        '''
		self.updateStartWaveNumbersButton = wx.Button(self, label=_('Update Start Wave Bibs'), style=wx.BU_EXACTFIT)
		self.Bind( wx.EVT_BUTTON, self.onUpdateStartWaveNumbers, self.updateStartWaveNumbersButton )
		hs.Add( self.updateStartWaveNumbersButton, 0, border = border, flag = flag )
		'''

        self.normalizeButton = wx.Button(self,
                                         label=_('Normalize'),
                                         style=wx.BU_EXACTFIT)
        self.Bind(wx.EVT_BUTTON, self.onNormalize, self.normalizeButton)
        hs.Add(self.normalizeButton, 0, border=border, flag=flag)

        hs.AddStretchSpacer()

        self.printButton = wx.Button(self,
                                     label=u'{}...'.format(_('Print')),
                                     style=wx.BU_EXACTFIT)
        self.Bind(wx.EVT_BUTTON, self.onPrint, self.printButton)
        hs.Add(self.printButton, 0, border=border, flag=flag)

        self.excelButton = wx.Button(self,
                                     label=u'{}...'.format(_('Excel')),
                                     style=wx.BU_EXACTFIT)
        self.Bind(wx.EVT_BUTTON, self.onExcel, self.excelButton)
        hs.Add(self.excelButton, 0, border=border, flag=flag)

        self.grid = ReorderableGrid(self)
        self.colNameFields = [
            (u'', None),
            (_('Category Type'), 'catType'),
            (_('Active'), 'active'),
            (_('Name'), 'name'),
            (_('Gender'), 'gender'),
            (_('Numbers'), 'catStr'),
            (_('Start\nOffset'), 'startOffset'),
            (_('Race\nLaps'), 'numLaps'),
            (_('Race\nMinutes'), 'raceMinutes'),
            (_('Lapped\nRiders\nContinue'), 'lappedRidersMustContinue'),
            (_('Distance'), 'distance'),
            (_('Dist.\nBy'), 'distanceType'),
            (_('First\nLap\nDist.'), 'firstLapDistance'),
            (_('80%\nLap\nTime'), 'rule80Time'),
            (_('CrossMgr\nEstimated\nLaps'), 'suggestedLaps'),
            (_('Publish'), 'publishFlag'),
            (_('Upload'), 'uploadFlag'),
            (_('Series'), 'seriesFlag'),
        ]
        self.computedFields = {'rule80Time', 'suggestedLaps'}
        self.colnames = [
            colName if not colName.startswith('_') else _('Name Copy')
            for colName, fieldName in self.colNameFields
        ]
        self.iCol = {
            fieldName: i
            for i, (colName, fieldName) in enumerate(self.colNameFields)
            if fieldName and not colName.startswith('_')
        }

        self.activeColumn = self.iCol['active']
        self.genderColumn = self.iCol['gender']
        self.numbersColumn = self.iCol['catStr']
        self.grid.CreateGrid(0, len(self.colnames))
        self.grid.SetRowLabelSize(32)
        self.grid.SetMargins(0, 0)
        for col, name in enumerate(self.colnames):
            self.grid.SetColLabelValue(col, name)

        self.cb = None

        self.boolCols = set()
        self.choiceCols = set()
        self.readOnlyCols = set()
        self.dependentCols = set()

        # Set column attributes for the table.
        for col, (colName, fieldName) in enumerate(self.colNameFields):
            attr = gridlib.GridCellAttr()

            if fieldName is None:
                attr.SetRenderer(CategoryIconRenderer())
                attr.SetAlignment(wx.ALIGN_LEFT, wx.ALIGN_CENTRE)
                attr.SetReadOnly(True)
                self.readOnlyCols.add(col)

            elif fieldName == 'catType':
                self.catTypeWidth = 64
                attr.SetEditor(
                    gridlib.GridCellChoiceEditor(self.CategoryTypeChoices,
                                                 False))
                attr.SetAlignment(wx.ALIGN_LEFT, wx.ALIGN_CENTRE)
                self.choiceCols.add(col)

            elif fieldName in {
                    'active', 'lappedRidersMustContinue', 'publishFlag',
                    'uploadFlag', 'seriesFlag'
            }:
                boolEditor = gridlib.GridCellBoolEditor()
                boolEditor.UseStringValues('1', '0')
                attr.SetEditor(boolEditor)
                attr.SetRenderer(gridlib.GridCellBoolRenderer())
                attr.SetAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
                self.boolCols.add(col)
                if fieldName == 'lappedRidersMustContinue':
                    self.dependentCols.add(col)

            elif fieldName == 'gender':
                attr.SetEditor(
                    gridlib.GridCellChoiceEditor(
                        [_('Open'), _('Men'), _('Women')], False))
                self.choiceCols.add(col)

            elif fieldName == 'startOffset':
                attr.SetEditor(TimeEditor())
                attr.SetAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
                self.dependentCols.add(col)

            elif fieldName == 'numLaps':
                attr.SetEditor(wx.grid.GridCellNumberEditor())
                attr.SetAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
                self.dependentCols.add(col)

            elif fieldName == 'raceMinutes':
                attr.SetEditor(wx.grid.GridCellNumberEditor())
                attr.SetAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
                self.dependentCols.add(col)

            elif fieldName in ['rule80Time', 'suggestedLaps']:
                attr.SetReadOnly(True)
                attr.SetAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
                self.readOnlyCols.add(col)
                self.dependentCols.add(col)

            elif fieldName in ['distance', 'firstLapDistance']:
                attr.SetEditor(gridlib.GridCellFloatEditor(7, 3))
                attr.SetRenderer(gridlib.GridCellFloatRenderer(7, 3))
                attr.SetAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
                self.dependentCols.add(col)

            elif fieldName == 'distanceType':
                attr.SetEditor(
                    gridlib.GridCellChoiceEditor(self.DistanceTypeChoices,
                                                 False))
                attr.SetAlignment(wx.ALIGN_RIGHT, wx.ALIGN_CENTRE)
                self.choiceCols.add(col)
                self.dependentCols.add(col)

            elif colName == '_name2':
                attr.SetAlignment(wx.ALIGN_LEFT, wx.ALIGN_CENTRE)
                attr.SetBackgroundColour(wx.Colour(240, 240, 240))
                attr.SetReadOnly(True)

            self.grid.SetColAttr(col, attr)

        self.Bind(gridlib.EVT_GRID_CELL_LEFT_CLICK, self.onGridLeftClick)
        self.Bind(gridlib.EVT_GRID_SELECT_CELL, self.onCellSelected)
        self.Bind(gridlib.EVT_GRID_CELL_CHANGED, self.onCellChanged)
        self.Bind(gridlib.EVT_GRID_EDITOR_CREATED, self.onEditorCreated)

        vs.Add(hs, 0, flag=wx.EXPAND | wx.ALL, border=4)
        vs.Add(self.grid, 1, flag=wx.GROW | wx.ALL | wx.EXPAND)

        self.rowCur = 0
        self.colCur = 0
        self.SetSizer(vs)
コード例 #17
0
ファイル: newimage.py プロジェクト: marcobarilari/fsleyes
    def __init__(self, parent, shape, pixdim, affine, dtype):
        """Create a ``NewImageDialog``.

        :arg parent: ``wx`` parent object
        :arg shape:  Tuple of three initial shape values
        :arg pixdim: Tuple of three initial pixdim values
        :arg affine: Initial affine, assumed to be a ``(4, 4)`` ``numpy``
                     array
        :arg dtype:  Initial ``numpy`` dtype. Must be one of ``float32``,
                     ``float64``, ``uint8``, ``int16``, or ``int32``.
        """

        if shape is None: shape = (100, 100, 100)
        if pixdim is None: pixdim = (1, 1, 1)
        if affine is None: affine = np.eye(4)
        if dtype is None: dtype = np.float32

        dtypeLabels = ['float', 'uchar', 'sshort', 'sint', 'double']
        dtypeValues = [np.float32, np.uint8, np.int16, np.int32, np.float64]
        dtypeLabels = [strings.labels[self, l] for l in dtypeLabels]

        if dtype in dtypeValues: dtype = dtypeValues.index(dtype)
        else: dtype = 0

        self.__dtypeValues = dtypeValues

        wx.Dialog.__init__(self,
                           parent,
                           title=strings.titles[self],
                           style=wx.DEFAULT_DIALOG_STYLE)

        dtypeLabel = strings.labels[self, 'dtype']
        shapeLabel = strings.labels[self, 'shape']
        pixdimLabel = strings.labels[self, 'pixdim']
        affineLabel = strings.labels[self, 'affine']
        linkLabel = strings.labels[self, 'link']
        okLabel = strings.labels[self, 'ok']
        cancelLabel = strings.labels[self, 'cancel']

        self.__dtypeLabel = wx.StaticText(self, label=dtypeLabel)
        self.__shapeLabel = wx.StaticText(self, label=shapeLabel)
        self.__pixdimLabel = wx.StaticText(self, label=pixdimLabel)
        self.__affineLabel = wx.StaticText(self, label=affineLabel)
        self.__xLabel = wx.StaticText(self, label='X')
        self.__yLabel = wx.StaticText(self, label='Y')
        self.__zLabel = wx.StaticText(self, label='Z')
        self.__dtype = wx.Choice(self, choices=dtypeLabels)
        self.__ok = wx.Button(self, id=wx.ID_OK, label=okLabel)
        self.__cancel = wx.Button(self, id=wx.ID_CANCEL, label=cancelLabel)

        self.__dtype.SetSelection(dtype)

        shapewidgets = []
        pixdimwidgets = []

        for i in range(3):
            shapew = floatspin.FloatSpinCtrl(self,
                                             minValue=1,
                                             maxValue=2**64 - 1,
                                             increment=1,
                                             value=shape[i],
                                             style=floatspin.FSC_INTEGER)
            pixdimw = floatspin.FloatSpinCtrl(self,
                                              minValue=-100,
                                              maxValue=100,
                                              increment=0.5,
                                              value=pixdim[i])

            shapewidgets.append(shapew)
            pixdimwidgets.append(pixdimw)

        self.__shapex = shapewidgets[0]
        self.__shapey = shapewidgets[1]
        self.__shapez = shapewidgets[2]
        self.__pixdimx = pixdimwidgets[0]
        self.__pixdimy = pixdimwidgets[1]
        self.__pixdimz = pixdimwidgets[2]
        self.__link = wx.CheckBox(self, label=linkLabel)
        self.__link.SetValue(True)

        self.__affine = wxgrid.Grid(self)
        self.__affine.SetDefaultEditor(wxgrid.GridCellFloatEditor(-1, 2))
        self.__affine.CreateGrid(4, 4)
        self.__affine.HideRowLabels()
        self.__affine.HideColLabels()
        for i in range(4):
            self.__affine.SetColFormatFloat(i, -1, 2)
        self.affine = affine

        self.__mainSizer = wx.BoxSizer(wx.VERTICAL)
        self.__dtypeSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.__affineSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.__affineLblSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.__shapepixSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.__shapepixGrid = wx.FlexGridSizer(4, 3, 0, 0)
        self.__buttonSizer = wx.BoxSizer(wx.HORIZONTAL)

        self.__dtypeSizer.Add((1, 1), proportion=1)
        self.__dtypeSizer.Add(self.__dtypeLabel)
        self.__dtypeSizer.Add(self.__dtype)
        self.__dtypeSizer.Add((1, 1), proportion=1)

        self.__shapepixGrid.Add((1, 1))
        self.__shapepixGrid.Add(self.__shapeLabel)
        self.__shapepixGrid.Add(self.__pixdimLabel)
        self.__shapepixGrid.Add(self.__xLabel)
        self.__shapepixGrid.Add(self.__shapex)
        self.__shapepixGrid.Add(self.__pixdimx)
        self.__shapepixGrid.Add(self.__yLabel)
        self.__shapepixGrid.Add(self.__shapey)
        self.__shapepixGrid.Add(self.__pixdimy)
        self.__shapepixGrid.Add(self.__zLabel)
        self.__shapepixGrid.Add(self.__shapez)
        self.__shapepixGrid.Add(self.__pixdimz)
        self.__shapepixSizer.Add((1, 1), proportion=1)
        self.__shapepixSizer.Add(self.__shapepixGrid)
        self.__shapepixSizer.Add((1, 1), proportion=1)

        self.__affineSizer.Add((1, 1), proportion=1)
        self.__affineSizer.Add(self.__affine)
        self.__affineSizer.Add((1, 1), proportion=1)

        self.__affineLblSizer.Add(self.__affineLabel)
        self.__affineLblSizer.Add((10, 1))
        self.__affineLblSizer.Add(self.__link)

        self.__buttonSizer.Add((1, 1), proportion=1)
        self.__buttonSizer.Add(self.__ok)
        self.__buttonSizer.Add(self.__cancel)
        self.__buttonSizer.Add((1, 1), proportion=1)

        szargs = {'flag': wx.EXPAND | wx.LEFT | wx.RIGHT, 'border': 5}

        self.__mainSizer.Add((1, 10))
        self.__mainSizer.Add(self.__dtypeSizer, **szargs)
        self.__mainSizer.Add((1, 10))
        self.__mainSizer.Add(self.__shapepixSizer, **szargs)
        self.__mainSizer.Add((1, 10))
        self.__mainSizer.Add(self.__affineLblSizer, **szargs)
        self.__mainSizer.Add((1, 10))
        self.__mainSizer.Add(self.__affineSizer, **szargs)
        self.__mainSizer.Add((1, 10))
        self.__mainSizer.Add(self.__buttonSizer, **szargs)
        self.__mainSizer.Add((1, 10))

        self.SetSizer(self.__mainSizer)
        self.Layout()
        self.Fit()
        self.__ok.SetFocus()

        self.__pixdimx.Bind(floatspin.EVT_FLOATSPIN, self.__onPixdim)
        self.__pixdimy.Bind(floatspin.EVT_FLOATSPIN, self.__onPixdim)
        self.__pixdimz.Bind(floatspin.EVT_FLOATSPIN, self.__onPixdim)
        self.__affine.Bind(wxgrid.EVT_GRID_CELL_CHANGED, self.__onAffine)
        self.__link.Bind(wx.EVT_CHECKBOX, self.__onLink)