예제 #1
0
 def __init__(self, parent, grid, cols=None):
     gridlib.Grid.__init__(self, parent)
     self.grid = grid
     self.backgroundColour = wx.Colour(216, 122, 50, 127)
     self.parent = parent
     self.SetGridLineColour(wx.LIGHT_GREY)
     self.CreateGrid(12, cols)
     self.SetColLabelAlignment(wx.ALIGN_LEFT, wx.ALIGN_BOTTOM)
     self.SetRowLabelSize(125)
     self.SetRowLabelAlignment(0, 0)
     self.SetRowLabelValue(0, "Variable name")
     self.SetRowLabelValue(1, "Alignment")
     self.SetRowLabelValue(2, "Label")
     self.SetRowLabelValue(3, "Measure")
     self.SetRowLabelValue(4, "Variable type")
     self.SetRowLabelValue(5, "Decimal places")
     self.SetRowLabelValue(6, "Missing values")
     self.SetRowLabelValue(7, " ")
     self.SetRowLabelValue(8, "Your data row 1")
     self.SetRowLabelValue(9, "Your data row 2")
     self.SetRowLabelValue(10, "Your data row 3")
     self.SetRowLabelValue(11, "Your data row 4")
     self.choices_align = ['Left', 'Centre', 'Right']
     self.choice_align = gridlib.GridCellChoiceEditor(
         self.choices_align, False)
     self.choices_measure = [
         'Nominal', 'Ordinal', 'Interval', 'Ratio', 'Unset'
     ]
     self.choice_measure = gridlib.GridCellChoiceEditor(
         self.choices_measure, False)
     self.choices_ivdv = ['None', 'IV', 'DV']
     self.choice_ivdv = gridlib.GridCellChoiceEditor(
         self.choices_ivdv, False)
     self.ResetGrid()
     gridlib.EVT_GRID_CELL_CHANGE(self, self.CellChanged)
예제 #2
0
    def __init__(self, parent, data):
        gridlib.PyGridTableBase.__init__(self)
        self.parent = parent
        self.data = data
        self.colorInactive = wx.SystemSettings.GetColour(
            wx.SYS_COLOUR_GRAYTEXT)

        self.editor = gridlib.GridCellChoiceEditor([
            'default', 'read-only', 'read-write', 'write-only', 'writeOnce',
            'read-writeOnce'
        ])

        self.attr_dd = gridlib.GridCellAttr()
        self.attr_dd.SetEditor(self.editor)

        self.attr_dg = gridlib.GridCellAttr()
        self.attr_dg.SetEditor(self.editor)
        self.attr_dg.SetTextColour(self.colorInactive)

        self.attr_ro = gridlib.GridCellAttr()
        self.attr_ro.SetReadOnly(True)
        self.attr_ro.SetTextColour(self.colorInactive)

        self.attr_g = gridlib.GridCellAttr()
        self.attr_g.SetTextColour(self.colorInactive)
    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()
예제 #4
0
 def AddBlankRow(self):
     self.m_grid5.AppendRows()
     row_num = self.m_grid5.GetNumberRows()
     # self.m_grid5.SetReadOnly(row_num - 1, 0, True)
     # self.m_grid5.SetReadOnly(row_num - 1, 1, True)
     editor1 = gridlib.GridCellChoiceEditor(models.ALL_PRODUCT_TYPE.keys(),
                                            allowOthers=False)
     self.m_grid5.SetCellEditor(row_num - 1, 0, editor1)
예제 #5
0
	def __init__(self, parent, Id, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0):
		gridlib.Grid.__init__(self, parent, Id)
		self.CreateGrid(100, MAX_COL + 1)

		# self.SetColLabelValue(ENUM_DEVICE_FLAG, u'')
		# self.SetColMinimalWidth(ENUM_DEVICE_FLAG, 50)

		self.SetColLabelValue(ENUM_DEVICE_DEV_TYPE, u'设备类型')
		self.SetColMinimalWidth(ENUM_DEVICE_DEV_TYPE, 180)

		self.SetColLabelValue(ENUM_DEVICE_DEV_ADDR, u'设备安装地址')
		self.SetColSize(ENUM_DEVICE_DEV_ADDR, 120)

		self.SetColLabelValue(ENUM_DEVICE_MANGR_IP, u'管理地址')
		self.SetColSize(ENUM_DEVICE_MANGR_IP, 120)

		self.SetColLabelValue(ENUM_DEVICE_SUBMASK_IP, u'子网掩码')
		self.SetColSize(ENUM_DEVICE_SUBMASK_IP, 120)

		self.SetColLabelValue(ENUM_DEVICE_GATEWAY_IP, u'默认网关')
		self.SetColSize(ENUM_DEVICE_GATEWAY_IP, 120)

		self.SetColLabelValue(ENUM_DEVICE_MANGR_VLAN, u'管理VLAN')
		self.SetColSize(ENUM_DEVICE_MANGR_VLAN, 120)

		self.SetColLabelValue(ENUM_DEVICE_BEGIN_VLAN, u'端口开始VLAN')
		self.SetColSize(ENUM_DEVICE_BEGIN_VLAN, 120)

		self.SetColLabelValue(ENUM_DEVICE_END_VLAN, u'端口结束VLAN')
		self.SetColSize(ENUM_DEVICE_END_VLAN, 120)

		self.SetRowLabelSize(60)

		self.AutoSizeColumns(setAsMin = False)

		for row in xrange(0,100):
			editor1 = gridlib.GridCellChoiceEditor(GetDeviceTypeList(), allowOthers=True)
			# self.SetCellValue(row, ENUM_DEVICE_DEV_TYPE, 'one')
			self.SetCellEditor(row, ENUM_DEVICE_DEV_TYPE, editor1)

			# editor2 = gridlib.GridCellBoolEditor()
			# self.SetCellEditor(row, ENUM_DEVICE_FLAG, editor2)
			# self.SetCellRenderer(row, ENUM_DEVICE_FLAG, gridlib.GridCellBoolRenderer())

		# for wxMSW
		# self.Bind(wx.EVT_COMMAND_RIGHT_CLICK, self.OnRightClick)
		# for wxGTK
		# self.Bind(wx.EVT_RIGHT_UP, self.OnRightClick)

		self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnCellDataChange)
		self.Bind(wx.grid.EVT_GRID_RANGE_SELECT, self.OnSelectRangeChange)
		self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnSelectChange)

		# self.SetBackgroundColour('#d9d6c3')
		self.SetDefaultRowSize(20)

		self.send_prompts = GetSendPrompt()
예제 #6
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)

        font = GetFont()
        self.title = wx.StaticText(
            self, wx.ID_ANY,
            "Enter each rider's qualifying time in hh:mm:ss.ddd format.  Use a colon ':' a space, or a dash '-' to separate hour, minute and seconds."
        )
        self.title.SetFont(font)

        self.renumberButton = wx.Button(self, wx.ID_ANY,
                                        'Renumber Bibs by Time')
        self.renumberButton.SetFont(font)
        self.renumberButton.Bind(wx.EVT_BUTTON, self.doRenumber)

        hs = wx.BoxSizer(wx.HORIZONTAL)
        hs.Add(self.title, 0, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL, border=6)
        hs.AddStretchSpacer()
        hs.Add(self.renumberButton, 0, flag=wx.ALL, border=6)

        self.headerNames = ['Bib', 'Name', 'Team', 'Time', 'Status']
        self.iTime = next(i for i, n in enumerate(self.headerNames)
                          if n.startswith('Time'))
        self.iStatus = next(i for i, n in enumerate(self.headerNames)
                            if n.startswith('Status'))

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

        # Set specialized editors for appropriate columns.
        self.grid.SetLabelFont(font)
        for col in six.moves.range(self.grid.GetNumberCols()):
            attr = gridlib.GridCellAttr()
            attr.SetFont(font)
            if col == self.iTime:
                attr.SetEditor(HighPrecisionTimeEditor())
                attr.SetAlignment(wx.ALIGN_RIGHT, wx.ALIGN_CENTRE)
            elif col == self.iStatus:
                attr.SetEditor(
                    gridlib.GridCellChoiceEditor(choices=['', 'DNQ']))
                attr.SetReadOnly(False)
                attr.SetAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
            else:
                if col == 0:
                    attr.SetRenderer(gridlib.GridCellNumberRenderer())
                attr.SetReadOnly(True)
            self.grid.SetColAttr(col, attr)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(hs, 0, flag=wx.ALL | wx.EXPAND, border=6)
        sizer.Add(self.grid, 1, flag=wx.EXPAND | wx.ALL, border=6)
        self.SetSizer(sizer)
예제 #7
0
    def __init__(self, parent, *args, **kwargs):
        # The base class must be initialized *first*
        gridlib.Grid.__init__(self, parent, -1)
        ##mixins.GridAutoEditMixin.__init__(self)

        self._table = GridTable(self, plugins={})
        self.SetTable(self._table)

        # Allow the user to type a string not in choices array
        # (see ComboCellEditor for a custom implementation bellow)
        self.RegisterDataType("combo", gridlib.GridCellStringRenderer(),
                              gridlib.GridCellChoiceEditor([], True))
예제 #8
0
 def AppendLine(self, func, key):
     global func_list
     if func not in func_list: return False
     self.AppendRows()
     r = self.GetNumberRows()
     self.SetCellEditor(r - 1, 0, gridlib.GridCellChoiceEditor(func_list))
     #        cedit=KeyEditor()
     #        self.SetCellEditor(r-1,1,cedit)
     #        self.SetCellEditor(r-1,1,mycell())
     self.SetCellValue(r - 1, 0, func)
     self.SetCellValue(r - 1, 1, key)
     self.SetReadOnly(r - 1, 1)
     self.MakeCellVisible(r - 1, 0)
예제 #9
0
    def __set_dev_grid(self):
        self.gridDev.Unbind(grid.EVT_GRID_EDITOR_CREATED)
        self.Unbind(grid.EVT_GRID_CELL_LEFT_CLICK)
        if wx.VERSION >= (3, 0, 0, 0):
            self.Unbind(grid.EVT_GRID_CELL_CHANGED)
        self.gridDev.ClearGrid()

        i = 0
        for device in self.devices:
            self.gridDev.SetReadOnly(i, self.COL_SEL, True)
            self.gridDev.SetCellRenderer(i, self.COL_SEL, TickCellRenderer())
            self.gridDev.SetCellValue(i, self.COL_NAME, device.name)
            cell = grid.GridCellChoiceEditor(sorted(DeviceGPS.TYPE),
                                             allowOthers=False)
            self.gridDev.SetCellValue(i, self.COL_TYPE,
                                      DeviceGPS.TYPE[device.type])
            self.gridDev.SetCellEditor(i, self.COL_TYPE, cell)

            if device.type == DeviceGPS.NMEA_SERIAL:
                self.gridDev.SetCellValue(i, self.COL_HOST,
                                          device.get_serial_desc())
                self.gridDev.SetReadOnly(i, self.COL_HOST, True)
            else:
                self.gridDev.SetCellValue(i, self.COL_HOST, device.resource)
                self.gridDev.SetReadOnly(i, self.COL_HOST, False)

            self.gridDev.SetCellValue(i, self.COL_TEST, '...')
            self.gridDev.SetCellAlignment(i, self.COL_SEL, wx.ALIGN_CENTRE,
                                          wx.ALIGN_CENTRE)
            i += 1

        self.index = limit(self.index, 0, len(self.devices) - 1)
        self.__select_row(self.index)
        self.index = self.index

        self.gridDev.AutoSize()
        font = self.gridDev.GetFont()
        dc = wx.WindowDC(self.gridDev)
        dc.SetFont(font)
        width, _height = dc.GetTextExtent(max(DeviceGPS.TYPE, key=len))
        self.gridDev.SetColSize(self.COL_TYPE, width * 1.5)

        self.gridDev.Bind(grid.EVT_GRID_EDITOR_CREATED, self.__on_create)
        self.Bind(grid.EVT_GRID_CELL_LEFT_CLICK, self.__on_click)
        if wx.VERSION >= (3, 0, 0, 0):
            self.Bind(grid.EVT_GRID_CELL_CHANGED, self.__on_change)
예제 #10
0
    def refresh(self, event):
        self.event = event

        start = event.starts[-1]
        state = event.competition.state

        font = GetFont()

        startPositions = start.startPositions
        Utils.AdjustGridSize(self.grid, rowsRequired=len(startPositions))

        self.grid.SetLabelFont(font)
        for col in six.moves.range(self.grid.GetNumberCols()):
            self.grid.SetColLabelValue(col, self.headerNames[col])
            attr = gridlib.GridCellAttr()
            attr.SetFont(font)
            if self.headerNames[col] == 'Bib':
                attr.SetAlignment(wx.ALIGN_CENTRE, wx.ALIGN_TOP)
                attr.SetReadOnly(True)
            elif col == 1 or col == 2:
                attr.SetReadOnly(True)
            elif self.headerNames[col].startswith('Status'):
                if len(start.getRemainingComposition()) > 2:
                    choices = ['DQ', 'DNF', '']
                    self.titleText.SetLabel(u'Restart Status Change')
                else:
                    choices = ['Inside', '']
                    self.titleText.SetLabel(u'Restart Position Change')
                attr.SetEditor(gridlib.GridCellChoiceEditor(choices=choices))
            self.grid.SetColAttr(col, attr)

        for row, p in enumerate(startPositions):
            rider = state.labels[p]
            for col, v in enumerate(
                [rider.bib, rider.full_name, rider.team, '']):
                self.grid.SetCellValue(row, col, u' {}'.format(v))

        self.grid.AutoSizeColumns(False)
        self.grid.AutoSizeRows(False)

        self.GetSizer().Layout()
        self.GetSizer().Fit(self)

        self.CentreOnParent(wx.BOTH)
        self.SetFocus()
예제 #11
0
    def __init__(self,gui,parent,dic,**kwargs):
        wgrid.Grid.__init__(self,parent,-1,**kwargs)
        self.rowString,self.colString,data=dic['rows'],dic['cols'],dic['data']
        if dic['rows']=='': self.rowString=['']*len(dic['data'])
        nrow, ncol = len(self.rowString),len(self.colString)
        self.chk = zeros((nrow,ncol))
        ln=[len(x) for x in self.rowString]
        self.SetRowLabelSize(min(max(ln)*8,170))
        lent = sum([len(x.replace(' ','')) for x in self.colString])
        if lent==0 : self.SetColLabelSize(0) # if all '', remove col headers
        self.CreateGrid(nrow,ncol);#print data
        for j,col in enumerate(self.colString):
            self.SetColLabelValue(j,col);
        for i,row in enumerate(self.rowString):
            self.SetRowLabelValue(i,row)
            ln = len(data[i])
            for j,col in enumerate(self.colString[:ln]):
                d = data[i][j]
                if type(d)==type([5,6]):
                    choice_editor = wgrid.GridCellChoiceEditor(d,False)
                    #choice_editor.SetCellAttr()
                    self.SetCellEditor(i,j, choice_editor)  
                    #self.SetCellValue(i, j, 1)
                elif type(d)==type(True):
                    e_boo = wgrid.GridCellBoolEditor()                       
                    self.SetCellEditor(i,j, e_boo)    
                    r_boo = wgrid.GridCellBoolRenderer()                       
                    self.SetCellRenderer(i,j, r_boo) 
                    self.chk[i,j] = 1
                    self.SetCellValue(i, j, str(d*1))
                else : 
                    # limit size cell if float
                    try : 
                        float(d)
                        #if 'e' not in d: d1 = d[:6]
                        d1 = str(d)[:9] #a real
                    except ValueError: 
                        d1 = str(d)
                    self.SetCellValue(i, j, d1)
                #self.SetCellSize(i,j,8,len(col)*4)

        self.AutoSizeColumns(True)
        self.AutoSizeRows(True)
        wx.EVT_KEY_DOWN(self, self.OnKey)
    def __set_dev_grid(self):
        self.gridDev.Unbind(grid.EVT_GRID_EDITOR_CREATED)
        self.Unbind(grid.EVT_GRID_CELL_LEFT_CLICK)
        self.Unbind(grid.EVT_GRID_CELL_CHANGE)
        self.gridDev.ClearGrid()

        i = 0
        for device in self.devices:
            self.gridDev.SetReadOnly(i, self.COL_SEL, True)
            self.gridDev.SetCellRenderer(i, self.COL_SEL,
                                         TickCellRenderer())
            self.gridDev.SetCellValue(i, self.COL_NAME, device.name)
            cell = grid.GridCellChoiceEditor(sorted(DeviceGPS.TYPE),
                                             allowOthers=False)
            self.gridDev.SetCellValue(i, self.COL_TYPE,
                                      DeviceGPS.TYPE[device.type])
            self.gridDev.SetCellEditor(i, self.COL_TYPE, cell)

            if device.type == DeviceGPS.NMEA_SERIAL:
                self.gridDev.SetCellValue(i, self.COL_HOST,
                                          device.get_serial_desc())
                self.gridDev.SetReadOnly(i, self.COL_HOST, True)
            else:
                self.gridDev.SetCellValue(i, self.COL_HOST, device.resource)
                self.gridDev.SetReadOnly(i, self.COL_HOST, False)

            self.gridDev.SetCellValue(i, self.COL_TEST, '...')
            self.gridDev.SetCellAlignment(i, self.COL_SEL,
                                          wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
            i += 1

        self.index = limit(self.index, 0, len(self.devices) - 1)
        self.__select_row(self.index)
        self.index = self.index

        self.gridDev.AutoSize()

        self.gridDev.Bind(grid.EVT_GRID_EDITOR_CREATED, self.__on_create)
        self.Bind(grid.EVT_GRID_CELL_LEFT_CLICK, self.__on_click)
        self.Bind(grid.EVT_GRID_CELL_CHANGE, self.__on_change)
예제 #13
0
 def __init__(self, parent):
     gridlib.Grid.__init__(self, parent, -1)
     self.SetDefaultCellAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
     self.CreateGrid(8, 2)
     self.EnableDragRowSize(False)
     self.SetColLabelValue(0, "X")
     self.SetColLabelValue(1, "Y")
     self.SetCellValue(0, 0, "Valeurs")
     self.SetCellValue(0, 1, "Valeur libre")
     self.liste = ["Valeur libre"] + ["Y%s"%(i+1) for i in range(param.nombre_courbes)]
     self.choix = gridlib.GridCellChoiceEditor(self.liste, False)
     self.SetCellEditor(0, 1, self.choix)
     self.SetReadOnly(0, 0, True)
     #self.SetCellAlignment(0, 1, wx.CENTER, wx.CENTER)
     self.SetRowLabelSize(30)
     self.SetColSize(0, 75)
     self.SetColSize(1, 75)
     self.AutoSizeRows(True)
     self.Bind(gridlib.EVT_GRID_CELL_LEFT_DCLICK, self.OnLeftDClick)
     self.Bind(gridlib.EVT_GRID_CELL_CHANGE, self.OnChange)
     self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
     self.SetGridCursor(1, 0)
예제 #14
0
    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")
예제 #15
0
    def __init__(self, parent, ncols, **kwargs):
        nrows = 6  # All rows: Name, Type, Low, Up, Mean, SD
        self.nrows = nrows
        self.ncols = ncols
        super().__init__(parent, nrows, ncols, toolbar_type=PriorToolBar, **kwargs)

        var_types = ["Uniform", "Gaussian"]
        self.model.data.index = ["Name", "Type", "Min", "Max", "Mean", "SD"]
        for i in range(ncols):
            choice_editor = gridlib.GridCellChoiceEditor(var_types)
            self.view.SetCellEditor(1, i, choice_editor)

        for i in range(2, nrows):
            attr = gridlib.GridCellAttr()
            attr.SetReadOnly(True)
            attr.SetBackgroundColour("Grey")
            self.view.SetRowAttr(i, attr)

        pub.subscribe(self.CheckObj, "Data_Changed", func=self.EnableRow)

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.model_name_text = wx.StaticText(parent, label='Class Name: ')
        sizer.Add(self.model_name_text, wx.RIGHT, border=7)
        self.model_name_view = sizer
예제 #16
0
    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
    def __init__(self, parent):
        gridlib.Grid.__init__(self, parent, -1, size=(200, 200), style=wx.WANTS_CHARS)
        self.moveTo = None
        
        self.listeValeurs = champs
        self.dictCategories = categories
        self.dictValeurs = {}

        self.Bind(wx.EVT_IDLE, self.OnIdle)
        
        # Création de la grille
        nbreLignes = len(self.listeValeurs) + len(self.dictCategories)
        self.CreateGrid(nbreLignes, 2)
        self.SetColSize(0, 240)
        self.SetColSize(1, 250)
        self.SetColLabelValue(0, "")
        self.SetColLabelValue(1, "")
        self.SetRowLabelSize(1)
        self.SetColLabelSize(1)
        
        # Remplissage avec les données
        IDcategorieEnCours = 0
        key = 0
        for valeurs in self.listeValeurs :
            
            # Récupération des valeurs
            code = valeurs[0]
            label = valeurs[1] + " :"
            type = valeurs[2]
            IDcategorie = valeurs[3]
            valeur = valeurs[4]
            sauvegarde = valeurs[5]
            controles = valeurs[6]
            
            # Indique que la valeur sera sauvegardée
            if sauvegarde == True : label = label[:-2] + " * :"
            
            if IDcategorieEnCours != IDcategorie :
                # Création d'une ligne CATEGORIE
                IDcategorieEnCours = IDcategorie
                self.SetRowLabelValue(key, "")
                self.SetCellValue(key, 0, self.dictCategories[IDcategorie])
                self.SetCellFont(key, 0, wx.Font(8, wx.DEFAULT , wx.NORMAL, wx.BOLD))
                self.SetCellBackgroundColour(key, 0, "#C5DDFA")
                self.SetReadOnly(key, 0, True)
                self.SetCellAlignment(key, 0, wx.ALIGN_LEFT, wx.ALIGN_CENTRE)
                self.SetCellValue(key, 1, "")
                self.SetCellBackgroundColour(key, 1, "#C5DDFA")
                self.SetReadOnly(key, 1, True)
                # Mémorisation dans le dictionnaire des données
                self.dictValeurs[key] = valeurs
                key += 1
                
            # Création d'une ligne de données
            
            # Entete de ligne
            self.SetRowLabelValue(key, "")
            
            # Création de la cellule LABEL
            self.SetCellValue(key, 0, label)
            self.SetCellBackgroundColour(key, 0, "#EEF4FB")
            self.SetReadOnly(key, 0, True)
            self.SetCellAlignment(key, 0, wx.ALIGN_RIGHT, wx.ALIGN_CENTRE)
            
            # Création de la cellule VALEUR
            if type == "texte" :
                nbreCaract = controles[-1][1]
                editor = gridlib.GridCellTextEditor()
                editor.SetParameters(str(nbreCaract))
                self.SetCellEditor(key, 1, editor)
                self.SetCellValue(key, 1, valeur[:nbreCaract])
            
            if type == "radio" :
                listeDonnees = []
                for controle in controles :
                    listeDonnees.append(controle[0])
                editor = gridlib.GridCellChoiceEditor( listeDonnees , False)
                self.SetCellEditor(key, 1, editor)
                self.SetCellValue(key, 1, valeur)
            
            # Mémorisation dans le dictionnaire des données
            self.dictValeurs[key] = valeurs
            key += 1
            
        # test all the events
        if 'phoenix' in wx.PlatformInfo:
            self.Bind(gridlib.EVT_GRID_CELL_CHANGED, self.OnCellChange)
        else :
            self.Bind(gridlib.EVT_GRID_CELL_CHANGE, self.OnCellChange)

        self.moveTo = (1, 1)
예제 #18
0
    def __init__(self, parent):
        EnablePanel.__init__(self, parent)
        self.box = wx.StaticBox(
            self,
            label='Result (right-click to enter Bib numbers from keyboard)')
        boxSizer = wx.StaticBoxSizer(self.box, wx.HORIZONTAL)

        self.event = None

        self.SetBackgroundColour(wx.WHITE)

        self.activeBar = EnableBar(self)
        self.activeBar.SetToolTip(
            wx.ToolTip('.\n'.join([
                'Record the Finish Order by dragging the row numbers in the table.',
                'Record DNF and DQ in the Status column.',
                'Then press OK or Cancel.'
            ])))

        vs = wx.BoxSizer(wx.VERTICAL)
        self.okButton = MakeRoundButton(self, 'OK')
        self.cancelButton = MakeRoundButton(self, 'Cancel', isCancel)
        vs.Add(self.okButton, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM, border=4)
        vs.Add(self.cancelButton, flag=wx.ALL, border=4)

        self.headerNames = [
            'Bib', 'Name', 'Team', 'Status', 'Warn', 'Rel', 'Time    '
        ]
        self.iColStatus = self.headerNames.index('Status')
        self.iColWarning = self.headerNames.index('Warn')
        self.iColRelegation = self.headerNames.index('Rel')

        self.grid = ReorderableGrid(self, style=wx.BORDER_SUNKEN)
        self.grid.CreateGrid(4, len(self.headerNames))
        self.grid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnClick)
        self.grid.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, self.OnRightClick)

        font = GetFont()
        self.grid.SetLabelFont(font)
        for col in six.moves.range(self.grid.GetNumberCols()):
            self.grid.SetColLabelValue(col, self.headerNames[col])
            self.grid.SetCellValue(
                0, col, self.headerNames[col])  # Add the label as data.
            attr = gridlib.GridCellAttr()
            attr.SetFont(font)
            if self.headerNames[col] == 'Bib':
                attr.SetAlignment(wx.ALIGN_CENTRE, wx.ALIGN_TOP)
                attr.SetReadOnly(True)
            elif self.headerNames[col].startswith('Time'):
                attr.SetEditor(HighPrecisionTimeEditor())
                attr.SetAlignment(wx.ALIGN_RIGHT, wx.ALIGN_CENTRE)
            elif col == 1 or col == 2:
                attr.SetReadOnly(True)
            elif col == self.iColStatus:
                attr.SetEditor(
                    gridlib.GridCellChoiceEditor(
                        choices=['DQ', 'DNF', 'DNS', '']))
            elif col == self.iColWarning or col == self.iColRelegation:
                attr.SetAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
                attr.SetEditor(gridlib.GridCellBoolEditor())
                attr.SetRenderer(gridlib.GridCellBoolRenderer())
            self.grid.SetColAttr(col, attr)

        self.grid.AutoSizeColumns(False)  # Resize to fit the column name.
        self.grid.AutoSizeRows(False)
        for col in six.moves.range(self.grid.GetNumberCols()):
            self.grid.SetCellValue(0, col, '')  # Remove the labels.

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

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(boxSizer, 1, flag=wx.EXPAND)
        self.SetSizer(sizer)
예제 #19
0
    def __init__(self, parent):
        EnablePanel.__init__(self, parent)
        self.box = wx.StaticBox(self, label='Start Positions')
        boxSizer = wx.StaticBoxSizer(self.box, wx.HORIZONTAL)

        self.SetBackgroundColour(wx.WHITE)

        self.event = None

        self.drawLotsBitmap = wx.Bitmap(
            os.path.join(Utils.getImageFolder(), 'dice.png'),
            wx.BITMAP_TYPE_PNG)
        self.drawLotsGreyBitmap = wx.Bitmap(
            os.path.join(Utils.getImageFolder(), 'dice_grey.png'),
            wx.BITMAP_TYPE_PNG)
        self.emptyBitmap = wx.Bitmap(self.drawLotsBitmap.GetWidth(),
                                     self.drawLotsBitmap.GetHeight(),
                                     self.drawLotsBitmap.GetDepth())

        dc = wx.MemoryDC()
        dc.SelectObject(self.emptyBitmap)
        dc.SetBrush(wx.WHITE_BRUSH)
        dc.Clear()
        dc.SelectObject(wx.NullBitmap)

        self.activeBar = EnableBar(self)
        self.activeBar.SetToolTip(
            wx.ToolTip(u'\n'.join([
                u'Record the Start Positions by dragging the row numbers in the table.',
                u'Set any DNS in the Status column.',
                u'Then press Start or Cancel.',
            ])))

        vs = wx.BoxSizer(wx.VERTICAL)
        self.startButton = MakeRoundButton(self, 'Start')
        self.cancelButton = MakeRoundButton(self, 'Cancel', isCancel)
        vs.Add(self.startButton, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM, border=4)
        vs.Add(self.cancelButton, flag=wx.ALL, border=4)

        self.headerNames = ['Bib', 'Name', 'Team', 'Status']
        self.iColStatus = 3
        self.grid = ReorderableGrid(self, style=wx.BORDER_SUNKEN)
        self.grid.CreateGrid(4, len(self.headerNames))

        font = wx.Font((0, FontSize), wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL,
                       wx.FONTWEIGHT_NORMAL)
        self.grid.SetLabelFont(font)
        for col in six.moves.range(self.grid.GetNumberCols()):
            self.grid.SetColLabelValue(col, self.headerNames[col])
            self.grid.SetCellValue(
                0, col, self.headerNames[col])  # Add the label as data.
            attr = gridlib.GridCellAttr()
            attr.SetFont(font)
            attr.SetReadOnly(True)
            if self.headerNames[col].startswith('Bib'):
                attr.SetAlignment(wx.ALIGN_CENTRE, wx.ALIGN_TOP)
            elif self.headerNames[col].startswith('Status'):
                attr.SetEditor(
                    gridlib.GridCellChoiceEditor(choices=['DNS', '']))
                attr.SetReadOnly(False)
            self.grid.SetColAttr(col, attr)

        self.grid.AutoSizeColumns(False)  # Resize to fit the column name.
        self.grid.AutoSizeRows(False)
        for col in six.moves.range(self.grid.GetNumberCols()):
            self.grid.SetCellValue(0, col, '')  # Remove the labels.

        self.drawLotsDisplay = wx.StaticBitmap(self, wx.ID_ANY,
                                               self.drawLotsBitmap)
        self.drawLotsDisplay.SetToolTip(
            wx.ToolTip(u'\n'.join([
                u"Dice are active when riders need to draw lots to select their positions.",
                u"Dice are inactive when riders' start positions are known.",
            ])))

        boxSizer.Add(self.activeBar, 0, flag=wx.ALL | wx.EXPAND, border=4)
        boxSizer.Add(vs, 0, flag=wx.ALL, border=4)
        boxSizer.Add(self.grid, 1, flag=wx.ALL | wx.EXPAND, border=4)
        boxSizer.Add(self.drawLotsDisplay,
                     0,
                     flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL,
                     border=4)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(boxSizer, 1, flag=wx.EXPAND)
        self.SetSizer(sizer)
예제 #20
0
    def ShowArg(self, record,n_id):
        """ 显示参数信息 Notebook """
        self.n_id = n_id
        pageId = n_id * 2 - 1
        flag = 0
        pageFocus = None
        for x in range(self.GetPageCount()):
            if pageId == self.GetPage(x).GetId():
                pageFocus = self.GetPage(x)
                flag = 1
            # if self.GetPage(x).GetId() > pageId:
            #     self.DeletePage(self.GetPageIndex(self.GetPage(x)))

        if flag != 0:

            pageFocus.SetFocus()
            self.Refresh()
        else:
            self.show_panel = wx.Panel(self, pageId, wx.DefaultPosition,
                                       wx.DefaultSize, wx.TAB_TRAVERSAL)
            title = u"设置抽样方法"
            self.AddPage(self.show_panel, title, True, wx.NullBitmap)

            show_panel = self.show_panel
            # show_panel 的布局,只有 scrollPanel 一个元素
            show_panel.bSizer = wx.BoxSizer(wx.VERTICAL)

            # 为实现滚动条加入 scrollPanel
            show_panel.scrolledWindow = wx.ScrolledWindow(show_panel, wx.ID_ANY,
                                                          wx.DefaultPosition, wx.DefaultSize, wx.HSCROLL | wx.VSCROLL)
            show_panel.scrolledWindow.SetScrollRate(5, 5)
            scrollPanel = show_panel.scrolledWindow
            # scrollPanel 的布局,元素为显示的控件
            show_panel.gbSizer = wx.GridBagSizer(5, 5)
            show_panel.gbSizer.SetFlexibleDirection(wx.BOTH)
            show_panel.gbSizer.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)

            show_panel.show_table_grid = grid.Grid(show_panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0)

            # Grid
            self.tablelen = len(record)
            show_panel.show_table_grid.CreateGrid(24, 13)
            # show_panel.show_table_grid.EnableEditing(True)
            # show_panel.show_table_grid.EnableGridLines(True)
            # # .show_table_grid.EnableDragGridSize(False)
            # show_panel.show_table_grid.SetMargins(0, 0)

            # Columns
            # show_panel.show_table_grid.EnableDragColMove(False)
            # show_panel.show_table_grid.EnableDragColSize(True)
            show_panel.show_table_grid.SetColLabelSize(30)
            show_panel.show_table_grid.SetColLabelAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
            show_panel.show_table_grid.SetColLabelValue(0, u"模型名称")
            show_panel.show_table_grid.SetColLabelValue(1, u"参数名称")
            show_panel.show_table_grid.SetColLabelValue(2, u"分布类型")
            show_panel.show_table_grid.SetColLabelValue(3, u"分布参数")
            show_panel.show_table_grid.SetColLabelValue(4, u"抽样方法")

            # Rows
            # show_panel.show_table_grid.EnableDragRowSize(True)
            show_panel.show_table_grid.SetRowLabelSize(80)
            show_panel.show_table_grid.SetRowLabelAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)

            # Label Appearance

            # Cell Defaults
            show_panel.show_table_grid.SetDefaultCellAlignment(wx.ALIGN_LEFT, wx.ALIGN_TOP)

            """"设置内容"""
            i = 0
            self.method_default = []
            for row in record:
                show_panel.show_table_grid.SetCellValue(i, 0, str(row[0]))
                show_panel.show_table_grid.SetCellValue(i, 1, str(row[1]))
                show_panel.show_table_grid.SetCellValue(i, 2, str(row[2]))
                show_panel.show_table_grid.SetCellValue(i, 3, str(row[3]))
                # 按照分布方式对应的可选抽样方法设置下拉框
                show_panel.show_table_grid.SetCellEditor(i, 4, grid.GridCellChoiceEditor(SM.available_method[str(row[2])]))
                # 设置默认值为第一个选项
                show_panel.show_table_grid.SetCellValue(i, 4, SM.available_method[str(row[2])][0])
                i = i + 1
                # 记录默认选项 以便在抽样方法设置时 作为默认值插入抽样方法列表
                self.method_default.append(SM.available_method[str(row[2])][0])

            show_panel.gbSizer.Add(show_panel.show_table_grid, wx.GBPosition(1,0),
                             wx.GBSpan(1, 3), wx.ALL, 2)

            # 分割线
            # show_panel.staticline = wx.StaticLine(show_panel, wx.ID_ANY, wx.DefaultPosition,
            #                                       wx.DefaultSize, wx.LI_HORIZONTAL)
            # show_panel.sStaticline = wx.StaticLine(show_panel, wx.ID_ANY, wx.DefaultPosition,
            #                                        wx.DefaultSize, wx.LI_HORIZONTAL)

            # 上方提示信息Panel
            commonTag.setModeltag(show_panel, n_id)


            # show_panel.bSSizer.Add(show_panel.sStaticline, 0, wx.EXPAND | wx.ALL, 2)



            # 下方btmPanel
            show_panel.btmPanel = wx.Panel(show_panel, wx.ID_ANY, wx.DefaultPosition,
                                           (-1, 40), wx.TAB_TRAVERSAL)
            show_panel.confirmPanel = wx.Panel(show_panel.btmPanel, wx.ID_ANY, wx.DefaultPosition,
                                            (280, 28), wx.TAB_TRAVERSAL)

            show_panel.m_button = wx.Button(show_panel.confirmPanel, wx.ID_ANY, u"确定",
                                        (0, 0), (100, 28), 0)
            show_panel.m_button.Bind(wx.EVT_BUTTON, self.select_method_test)
            show_panel.cancel = wx.Button(show_panel.confirmPanel, wx.ID_ANY, u"取消",
                                          (140, 0), (100, 28), 0)
            self.Bind(wx.EVT_BUTTON, self.Cancel, show_panel.cancel)

            # show_panel布局设置



            # show_panel.gbSizer.Add(show_panel.staticline, wx.GBPosition(26,0),
            #                  wx.GBSpan(1, 3), wx.ALL, 5)
            # show_panel.gbSizer.Add(show_panel.staticline, wx.GBPosition(26,0),
            #                  wx.GBSpan(1, 3), wx.ALL, 5)
            # # show_panel.bSizer.Add(scrollPanel, 0, wx.EXPAND | wx.ALL, 5)
            # show_panel.bSizer.Add(show_panel.staticline, 0, wx.EXPAND | wx.ALL, 5)
            show_panel.bSizer.Add(show_panel.btmPanel, 0, wx.EXPAND | wx.ALL, 5)


            show_panel.gbSizer.Add(show_panel.bSizer, wx.GBPosition(2,0),
                             wx.GBSpan(2, 5), wx.EXPAND | wx.ALL, 5)
            # show_panel.gbSizer.Add(show_panel.btmPanel, wx.GBPosition(27,0),
                             # wx.GBSpan(1, 3), wx.ALL, 5)
            # show_panel.SetSizer(show_panel.bSizer)
            scrollPanel.SetSizer(show_panel.gbSizer)
            scrollPanel.Layout()

            # 初始化confirmPanel位置
            x, y = show_panel.btmPanel.GetSize()
            w, h = show_panel.confirmPanel.GetSize()
            show_panel.confirmPanel.SetPosition((x - w - 25, y - h - 5))
예제 #21
0
    def ShowArg(self, record):

        self.show_panel = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition,
                                   wx.DefaultSize, wx.TAB_TRAVERSAL)
        self.AddPage(self.show_panel, u"显示参数信息", True, wx.NullBitmap)
        # self.show_panel 的布局,只有 scrollPanel 一个元素
        self.show_panel.bSizer = wx.BoxSizer(wx.VERTICAL)
        # 为实现滚动条加入 scrollPanel
        self.show_panel.scrolledWindow = wx.ScrolledWindow(
            self.show_panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
            wx.HSCROLL | wx.VSCROLL)
        self.show_panel.scrolledWindow.SetScrollRate(5, 5)
        scrollPanel = self.show_panel.scrolledWindow
        # scrollPanel 的布局,元素为显示的控件
        self.show_panel.gbSizer = wx.GridBagSizer(5, 5)
        self.show_panel.gbSizer.SetFlexibleDirection(wx.BOTH)
        self.show_panel.gbSizer.SetNonFlexibleGrowMode(
            wx.FLEX_GROWMODE_SPECIFIED)
        """"""

        self.show_panel.m_grid4 = grid.Grid(self.show_panel, wx.ID_ANY,
                                            wx.DefaultPosition, wx.DefaultSize,
                                            0)

        # Grid
        # 利用record的大小动态建立表长度
        self.tablelen = len(record)
        self.show_panel.m_grid4.CreateGrid(self.tablelen, 5)
        self.show_panel.m_grid4.EnableEditing(True)
        self.show_panel.m_grid4.EnableGridLines(True)
        self.show_panel.m_grid4.EnableDragGridSize(False)
        self.show_panel.m_grid4.SetMargins(0, 0)

        # Columns
        self.show_panel.m_grid4.EnableDragColMove(False)
        self.show_panel.m_grid4.EnableDragColSize(True)
        self.show_panel.m_grid4.SetColLabelSize(30)
        self.show_panel.m_grid4.SetColLabelAlignment(wx.ALIGN_CENTRE,
                                                     wx.ALIGN_CENTRE)
        self.show_panel.m_grid4.SetColLabelValue(0, "模型名称")
        self.show_panel.m_grid4.SetColLabelValue(1, "参数名称")
        self.show_panel.m_grid4.SetColLabelValue(2, "分布类型")
        self.show_panel.m_grid4.SetColLabelValue(3, "分布参数")
        self.show_panel.m_grid4.SetColLabelValue(4, "抽样方法")

        # Rows
        self.show_panel.m_grid4.EnableDragRowSize(True)
        self.show_panel.m_grid4.SetRowLabelSize(80)
        self.show_panel.m_grid4.SetRowLabelAlignment(wx.ALIGN_CENTRE,
                                                     wx.ALIGN_CENTRE)

        # Label Appearance

        # Cell Defaults
        self.show_panel.m_grid4.SetDefaultCellAlignment(
            wx.ALIGN_LEFT, wx.ALIGN_TOP)
        """"设置内容"""
        i = 0
        for row in record:
            self.show_panel.m_grid4.SetCellValue(i, 0, str(row[0]))
            self.show_panel.m_grid4.SetCellValue(i, 1, str(row[1]))
            self.show_panel.m_grid4.SetCellValue(i, 2, str(row[2]))
            self.show_panel.m_grid4.SetCellValue(i, 3, str(row[3]))
            # 按照分布方式对应的可选抽样方法设置下拉框
            self.show_panel.m_grid4.SetCellEditor(
                i, 4,
                grid.GridCellChoiceEditor(SM.available_method[str(row[2])]))
            i = i + 1
        """"""

        self.show_panel.bSizer.Add(self.show_panel.m_grid4, 1,
                                   wx.ALL | wx.EXPAND, 5)

        self.show_panel.m_button = wx.Button(self.show_panel, wx.ID_ANY, u"确定",
                                             wx.DefaultPosition,
                                             wx.DefaultSize, 0)
        self.show_panel.bSizer.Add(self.show_panel.m_button, 0, wx.ALL, 5)

        # Connect Events
        self.show_panel.m_button.Bind(wx.EVT_BUTTON, self.select_method_test)

        scrollPanel.SetSizer(self.show_panel.gbSizer)
        scrollPanel.Layout()
        self.show_panel.bSizer.Add(scrollPanel, 1, wx.EXPAND | wx.ALL, 5)
        self.show_panel.SetSizer(self.show_panel.bSizer)
        self.show_panel.Layout()
예제 #22
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)

        self.seriesNameLabel = wx.StaticText(self, label='Series Name:')
        self.seriesName = wx.TextCtrl(self)

        self.organizerNameLabel = wx.StaticText(self, label='Organizer:')
        self.organizerName = wx.TextCtrl(self)

        self.explanation = wx.StaticText(
            self,
            label=u'\n'.join([
                _("Add all the races in your Series."),
                _("Make sure the races are in chronological order."),
                _("You can change the order by dragging-and-dropping the first grey column in the table."
                  ),
                u'',
                _("Configure the Points Structures or Time Scoring parameters on the Scoring Criteria page."
                  ),
                _("Each race can have its own Points Structure.  For example, you could create 'Double Points' for one race."
                  ),
                u'',
                _("Race results are shown Last-to-First in the output by default."
                  ),
                _("You can change this on the Options page."),
            ]))

        self.grid = ReorderableGrid(self, style=wx.BORDER_SUNKEN)
        self.grid.DisableDragRowSize()
        self.grid.SetRowLabelSize(64)
        self.grid.CreateGrid(0, len(self.headerNames))
        for col in range(self.grid.GetNumberCols()):
            self.grid.SetColLabelValue(col, self.headerNames[col])

        self.pointsChoiceEditor = gridlib.GridCellChoiceEditor(
            [], allowOthers=False)
        attr = gridlib.GridCellAttr()
        attr.SetEditor(self.pointsChoiceEditor)
        self.grid.SetColAttr(self.PointsCol, attr)

        self.teamPointsChoiceEditor = gridlib.GridCellChoiceEditor(
            [], allowOthers=False)
        attr = gridlib.GridCellAttr()
        attr.SetEditor(self.teamPointsChoiceEditor)
        self.grid.SetColAttr(self.TeamPointsCol, attr)

        attr = gridlib.GridCellAttr()
        attr.SetReadOnly(True)
        self.grid.SetColAttr(self.RaceCol, attr)

        attr = gridlib.GridCellAttr()
        attr.SetAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
        self.grid.SetColAttr(self.GradeCol, attr)
        '''
		attr = gridlib.GridCellAttr()
		attr.SetReadOnly( True )
		self.grid.SetColAttr( self.RaceStatusCol, attr )
		'''

        attr = gridlib.GridCellAttr()
        attr.SetReadOnly(True)
        self.grid.SetColAttr(self.RaceFileCol, attr)

        self.grid.Bind(gridlib.EVT_GRID_CELL_CHANGED, self.onGridChange)
        self.gridAutoSize()
        self.grid.Bind(wx.grid.EVT_GRID_EDITOR_CREATED,
                       self.onGridEditorCreated)
        self.grid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK,
                       self.onEditRaceFileName)

        self.addButton = wx.Button(self, wx.ID_ANY, 'Add Races')
        self.addButton.Bind(wx.EVT_BUTTON, self.doAddRace)

        self.removeButton = wx.Button(self, wx.ID_ANY, 'Remove Race')
        self.removeButton.Bind(wx.EVT_BUTTON, self.doRemoveRace)

        fgs = wx.FlexGridSizer(rows=2, cols=2, vgap=2, hgap=2)
        fgs.AddGrowableCol(1, proportion=1)

        fgs.Add(self.seriesNameLabel,
                flag=wx.ALIGN_CENTRE_VERTICAL | wx.ALIGN_RIGHT)
        fgs.Add(self.seriesName, flag=wx.EXPAND)
        fgs.Add(self.organizerNameLabel,
                flag=wx.ALIGN_CENTRE_VERTICAL | wx.ALIGN_RIGHT)
        fgs.Add(self.organizerName, flag=wx.EXPAND)

        hs = wx.BoxSizer(wx.HORIZONTAL)
        hs.Add(self.addButton, 0, flag=wx.ALL, border=4)
        hs.Add(self.removeButton, 0, flag=wx.ALL, border=4)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(fgs, 0, flag=wx.EXPAND | wx.ALL, border=4)
        sizer.Add(self.explanation, 0, flag=wx.EXPAND | wx.ALL, border=4)
        sizer.Add(hs, 0, flag=wx.EXPAND)
        sizer.Add(self.grid, 1, flag=wx.EXPAND | wx.ALL, border=6)
        self.SetSizer(sizer)
예제 #23
0
 def editor(self):
     return gridlib.GridCellChoiceEditor(self.values)