Exemplo n.º 1
0
 def setupGrid(self, grid, states, stateTypes):
     nStates = len(states)
     
     grid.SetDefaultColSize(70)
     grid.CreateGrid(nStates, nStates)
     
     for i in range(nStates):
         grid.SetRowLabelValue(i, states[i])
         grid.SetColLabelValue(i, states[i])
         grid.SetReadOnly(i, i)
         grid.SetCellBackgroundColour(i, i, wx.LIGHT_GREY)
         grid.SetCellTextColour(i, i, wx.LIGHT_GREY)
         
         if (stateTypes[i] == fluor.TO_ONLY):
             for j in range(nStates):
                 grid.SetReadOnly(i, j)
                 grid.SetCellBackgroundColour(i, j, wx.LIGHT_GREY)
                 grid.SetCellTextColour(i, j, wx.LIGHT_GREY)
         
         if (stateTypes[i] == fluor.FROM_ONLY):
             for j in range(nStates):
                 grid.SetReadOnly(j, i)
                 grid.SetCellBackgroundColour(j, i, wx.LIGHT_GREY)
                 grid.SetCellTextColour(j, i, wx.LIGHT_GREY)
                 
     grid.SetMinSize(grid.BestSize)
Exemplo n.º 2
0
def setup_grid(grid, title):
    """
    This function only works with type wx.grid.Grid
    The it will create a grid that is like the one found in LinkCtrl/View.
    :param grid:
    :return:
    """

    grid.CreateGrid(6, 2)
    grid.EnableEditing(False)
    grid.EnableGridLines(True)
    grid.SetGridLineColour(wx.Colour(0, 0, 0))
    grid.EnableDragGridSize(False)

    # Columns
    grid.EnableDragColMove(False)
    grid.EnableDragColSize(True)
    grid.SetColLabelSize(0)
    grid.SetColLabelAlignment(wx.ALIGN_CENTER, wx.ALIGN_CENTER)
    grid.SetColSize(0, 110)

    # Rows
    grid.EnableDragRowSize(True)
    grid.SetRowLabelSize(0)
    grid.SetRowLabelAlignment(wx.ALIGN_CENTER, wx.ALIGN_CENTER)

    # Defaults
    grid.SetDefaultCellBackgroundColour(wx.Colour(255, 255, 255))  # white
    grid.SetDefaultCellAlignment(wx.ALIGN_LEFT, wx.ALIGN_TOP)

    # Set Cell Values
    grid.SetCellValue(0, 0, " %s" % title)
    grid.SetCellValue(1, 0, " Variable Name")
    grid.SetCellValue(2, 0, " Geometry Type")
    grid.SetCellValue(3, 0, " Geometry Count")
    grid.SetCellValue(4, 0, " Coordinate System")
    grid.SetCellValue(5, 0, " Spatial Extent")

    # set the default background color
    grid.SetDefaultCellBackgroundColour('WHITE')

    # change color and size of header
    grid.SetCellSize(0, 0, 1, 2)  # span cols 0 and 1
    grid.SetCellBackgroundColour(0, 0, wx.Colour(195, 195, 195))  # Grey

    # set the table column size
    grid.SetColSize(0, 133)
    grid.SetColSize(1, 155)

    # change color of properties
    for i in range(1, grid.GetNumberRows()):
        grid.SetCellBackgroundColour(i, 0, wx.Colour(250, 250,
                                                     250))  # light Grey

    grid.SetGridLineColour(wx.Colour(195, 195, 195))
Exemplo n.º 3
0
    def _updateColAttrs(self, grid, row=None):
        """
        wxGrid -> update the column attributes to add the
        appropriate renderer given the column name.

        Otherwise default to the default renderer.
        """

        for row in range(self.GetNumberRows()):
            row_highlights = self.Highlights.get(row, {})
            for col in range(self.GetNumberCols()):
                editor = None
                renderer = None
                colname = self.GetColLabelValue(col, False)

                editortype = self.columnTypes.get(colname, None)
                if editortype is not None:
                    editor = editortype(self, row, col)

                grid.SetCellEditor(row, col, editor)
                grid.SetCellRenderer(row, col, renderer)

                highlight_colours = row_highlights.get(
                    colname.lower(), [(wx.WHITE, wx.BLACK)])[-1]
                grid.SetCellBackgroundColour(row, col, highlight_colours[0])
                grid.SetCellTextColour(row, col, highlight_colours[1])
            self.ResizeRow(grid, row)
Exemplo n.º 4
0
    def __init__(self, filename):
        wx.Frame.__init__(self, None, title="Grid Attributes", size=(600, 300))
        data = xlrd.open_workbook(filename, formatting_info=True)

        table = data.sheets()[0]

        nrow = table.nrows
        ncol = table.ncols

        grid = wx.grid.Grid(self)
        grid.CreateGrid(nrow, ncol)
        for col in range(ncol):
            for row in range(nrow):
                cell = table.cell(row, col)
                if cell.ctype == 1:
                    content = cell.value.encode("UTF-8")
                elif cell.ctype == 2:
                    content = str(cell.value)

                grid.SetCellValue(row, col, content)

        grid.SetCellTextColour(1, 1, "red")
        grid.SetCellFont(1, 1, wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD))
        grid.SetCellBackgroundColour(2, 2, "light blue")

        attr = wx.grid.GridCellAttr()
        attr.SetTextColour("navyblue")
        attr.SetBackgroundColour("pink")
        attr.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD))

        grid.SetAttr(2, 0, attr)

        grid.SetRowAttr(0, attr)
Exemplo n.º 5
0
    def _updateColAttrs(self, grid):
        """
        wxGrid -> update the column attributes to add the
        appropriate renderer given the column name.

        Otherwise default to the default renderer.
        """

        for row in range(self.GetNumberRows()):
            for col in range(self.GetNumberCols()):
                editor = None
                renderer = None
                colname = self.GetColLabelValue(col, False)

                if colname in [
                        "Name", "Initial", "Description", "OnChange", "Options"
                ]:
                    editor = wx.grid.GridCellTextEditor()
                elif colname == "Class":
                    editor = wx.grid.GridCellChoiceEditor()
                    editor.SetParameters("input,memory,output")
                elif colname == "Type":
                    pass
                else:
                    grid.SetReadOnly(row, col, True)

                grid.SetCellEditor(row, col, editor)
                grid.SetCellRenderer(row, col, renderer)

                grid.SetCellBackgroundColour(row, col, wx.WHITE)
            self.ResizeRow(grid, row)
Exemplo n.º 6
0
    def __init__(self, parent):
        wx.Frame.__init__(self, parent)

        # Create a wxGrid object
        grid = wx.grid.Grid(self, -1)

        # Then we call CreateGrid to set the dimensions of the grid
        # (100 rows and 10 columns in this example)
        grid.CreateGrid(100, 10)

        # We can set the sizes of individual rows and columns
        # in pixels

        grid.SetColSize(5, 200)
        # And set grid cell contents as strings
        grid.SetCellValue(0, 0, 'wxGrid is good')

        # We can specify that some cells are read.only
        grid.SetCellValue(0, 3, 'This is read.only')
        grid.SetReadOnly(0, 3)

        # Colours can be specified for grid cell contents
        grid.SetCellValue(3, 3, 'green on grey')
        grid.SetCellTextColour(3, 3, wx.GREEN)
        grid.SetCellBackgroundColour(3, 3, wx.LIGHT_GREY)

        # We can specify the some cells will store numeric
        # values rather than strings. Here we set grid column 5
        # to hold floating point values displayed with width of 6
        # and precision of 2
        grid.SetColFormatFloat(5, 6, 2)
        grid.SetCellValue(0, 6, '3.1415')

        self.Show()
Exemplo n.º 7
0
    def __init__(self, parent):
        wx.Frame.__init__(self, parent, title='Statistics')

        wtl = CsvTimeLogger()
        statistics = wtl.get_statistics()
        panel = wx.Panel(self)
        top_sizer = wx.BoxSizer(wx.VERTICAL)

        grid = wx.grid.Grid(self, -1)
        grid.CreateGrid(len(statistics), 2)  # + 1 due to summary row at end
        grid.SetColLabelValue(0, "Day")
        grid.SetColLabelValue(1, "Worked")
        grid.SetRowLabelSize(0)

        for i, (k, v) in enumerate(statistics.items()):
            grid.SetCellValue(i, 1, format_timedelta(v))
            grid.SetCellAlignment(i, 1, wx.ALIGN_RIGHT, wx.ALIGN_CENTER)
            if isinstance(k, dt.date):
                grid.SetCellValue(i, 0, k.strftime('%a %Y-%m-%d'))
                grid.SetCellAlignment(i, 0, wx.ALIGN_RIGHT, wx.ALIGN_CENTER)

                rel_extra_time = v.total_seconds() / dt.timedelta(hours=4).seconds
                grid.SetCellBackgroundColour(i, 1, get_color_red_white_blue(rel_extra_time))
            else:
                grid.SetCellValue(i, 0, k)

        grid.AutoSize()
        top_sizer.Add(grid, 0, wx.CENTER)
        panel.SetSizer(top_sizer)
        top_sizer.Fit(self)
        self.Show()
Exemplo n.º 8
0
    def _updateColAttrs(self, grid):
        """
        wx.grid.Grid -> update the column attributes to add the
        appropriate renderer given the column name.

        Otherwise default to the default renderer.
        """

        for row in range(self.GetNumberRows()):
            row_highlights = self.Highlights.get(row, {})
            for col in range(self.GetNumberCols()):
                editor = None
                renderer = None
                colname = self.GetColLabelValue(col, False)
                if col != 0:
                    grid.SetReadOnly(row, col, False)
                    if colname == "Name":
                        editor = wx.grid.GridCellTextEditor()
                        renderer = wx.grid.GridCellStringRenderer()
                    elif colname == "Initial Value":
                        editor = wx.grid.GridCellTextEditor()
                        renderer = wx.grid.GridCellStringRenderer()
                    elif colname == "Type":
                        editor = wx.grid.GridCellTextEditor()
                else:
                    grid.SetReadOnly(row, col, True)

                grid.SetCellEditor(row, col, editor)
                grid.SetCellRenderer(row, col, renderer)

                highlight_colours = row_highlights.get(
                    colname.lower(), [(wx.WHITE, wx.BLACK)])[-1]
                grid.SetCellBackgroundColour(row, col, highlight_colours[0])
                grid.SetCellTextColour(row, col, highlight_colours[1])
            self.ResizeRow(grid, row)
def cellValueChanged(event,variableObj):
    grid = event.GetEventObject()
    currentCellRow=event.GetRow()
    currentCellCol=event.GetCol()
    gridIndex = variableObj.gridList.index(grid)
    currentCellAddress = addressWxpythonToExcelFormat(currentCellRow,currentCellCol)
    if(((currentCellCol!=0) and (currentCellRow!=0)) == False):
        grid.SetCellBackgroundColour(currentCellRow,currentCellCol,variableObj.constantObj.COLOR_LABEL)  #changing color of label if new element is added .


#######################################################################################################################################################
#######################################################################################################################################################
#######################################################################################################################################################
#######################################################################################################################################################
#######################################################################################################################################################
#######################################################################################################################################################
       ################################value change for all the cells containing the cell address whose value has just been changed###############

    #currentCellAddress is the cell whose value is changed by user
    #cell is the cellAddress in formula list
    else:
        for cell in variableObj.formulas[gridIndex]:                #cell is current Cell Address from the formula that is being searched
            formula = variableObj.formulas[gridIndex][cell]         #cell formula is stored in formula
            if(currentCellAddress in formula):                      #if the cell formula contains the value Changed cell
                row,col = addressExcelToWxpythonFormat(cell)        #change the address from 'A1" format to row=0,col=0 format
                formulaParser(variableObj,grid,gridIndex,row,col,formula)           #formula parser called
Exemplo n.º 10
0
def setGridProperties(variableObj):
    for grid in variableObj.gridList:
        grid.SetCellBackgroundColour(0,0,variableObj.constantObj.COLOR_LABEL)   #SETTING COLOR FOR CELL (0,0)
        grid.SetSize((variableObj.maximizedFrameSize[0])-100,variableObj.maximizedFrameSize[1] - 150)   #setting the (width, height) in pixels of the grid
        grid.SetColMinimalAcceptableWidth(70)                                  #setting minimum length of a column possible(in pixel)
        grid.SetDefaultCellAlignment(ALIGN_CENTRE,ALIGN_CENTRE)                #values will be centered aligned
        grid.AutoSizeColumns()                                                 #column will be set to the size of longest element in the column
Exemplo n.º 11
0
 def CreateGrid(self, parent):
     grid = wx.grid.Grid(parent)
     grid.CreateGrid(len(data), len(data[0]))
     for r in range(len(data)):
         for c in range(len(data[r])):
             grid.SetColLabelValue(c, column_names[c])
             grid.SetCellValue(r, c, data[r][c])
             grid.SetCellAlignment(r, c, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
             font = wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD, False)
             grid.SetCellFont(r, c, font)
             if r % 2 == 0:
                 grid.SetCellBackgroundColour(r, c, "SEA green")
             else:
                 grid.SetCellBackgroundColour(r, c, "SLATE blue")
     grid.AutoSize()
     return grid
Exemplo n.º 12
0
def formulaEntryIsDeleted(variableObj,grid,gridIndex,row,col):
    cellAddress=addressWxpythonToExcelFormat(row,col)
    if(variableObj.formulas[gridIndex].get(cellAddress) != None):                           #checking if the formula exists in the variableObj.formulas
        grid.SetCellBackgroundColour(row,col,variableObj.constantObj.COLOR_FILLED_CELL)   #reset cell color to white
        grid.SetCellValue(row,col,"")                                                     #reset cell value to null
        del variableObj.formulas[gridIndex][cellAddress]                                  #delete the formula from the formulas variable
        variableObj.formulaEntry.SetBackgroundColour(variableObj.constantObj.COLOR_FILLED_CELL)      # formula entry color to white
        grid.SetReadOnly(row, col, False)
Exemplo n.º 13
0
    def _updateColAttrs(self, grid):
        """
        wx.grid.Grid -> update the column attributes to add the
        appropriate renderer given the column name.

        Otherwise default to the default renderer.
        """

        for col in range(self.GetNumberCols()):
            attr = wx.grid.GridCellAttr()
            attr.SetAlignment(self.ColAlignements[col], wx.ALIGN_CENTRE)
            grid.SetColAttr(col, attr)
            grid.SetColSize(col, self.ColSizes[col])

        for row in range(self.GetNumberRows()):
            row_highlights = self.Highlights.get(row, {})
            for col in range(self.GetNumberCols()):
                editor = None
                renderer = None
                colname = self.GetColLabelValue(col, False)
                grid.SetReadOnly(row, col, False)
                if colname == "Name":
                    editor = wx.grid.GridCellTextEditor()
                    renderer = wx.grid.GridCellStringRenderer()
                elif colname == "Interval":
                    editor = DurationCellEditor(self)
                    renderer = wx.grid.GridCellStringRenderer()
                    if self.GetValueByName(row, "Triggering") != "Cyclic":
                        grid.SetReadOnly(row, col, True)
                elif colname == "Single":
                    editor = wx.grid.GridCellChoiceEditor()
                    editor.SetParameters(self.Parent.VariableList)
                    if self.GetValueByName(row, "Triggering") != "Interrupt":
                        grid.SetReadOnly(row, col, True)
                elif colname == "Triggering":
                    editor = wx.grid.GridCellChoiceEditor()
                    editor.SetParameters(
                        ",".join([""] + map(_, GetTaskTriggeringOptions())))
                elif colname == "Type":
                    editor = wx.grid.GridCellChoiceEditor()
                    editor.SetParameters(self.Parent.TypeList)
                elif colname == "Priority":
                    editor = wx.grid.GridCellNumberEditor()
                    editor.SetParameters("0,65535")
                elif colname == "Task":
                    editor = wx.grid.GridCellChoiceEditor()
                    editor.SetParameters(self.Parent.TaskList)

                grid.SetCellEditor(row, col, editor)
                grid.SetCellRenderer(row, col, renderer)

                highlight_colours = row_highlights.get(
                    colname.lower(), [(wx.WHITE, wx.BLACK)])[-1]
                grid.SetCellBackgroundColour(row, col, highlight_colours[0])
                grid.SetCellTextColour(row, col, highlight_colours[1])
            self.ResizeRow(grid, row)
Exemplo n.º 14
0
 def set_scores(self, players_list, grid):  # set best scores in the right table
     counter = 0
     num = len(players_list)/2
     for i in range(int(num)):
         for j in range(2):
             grid.SetReadOnly(i, j, True)
             grid.SetCellFont(i, j, wx.Font(16, wx.SWISS, wx.NORMAL, wx.BOLD))
             grid.SetCellBackgroundColour(i, j,(206, 126, 206))
             grid.SetCellValue(i, j, players_list[counter])
             counter = counter + 1
Exemplo n.º 15
0
    def init_grid(self, grid):
        # Grid
        grid.CreateGrid(7, 2)
        grid.EnableEditing(False)
        grid.EnableGridLines(True)
        grid.SetGridLineColour(wx.Colour(0, 0, 0))
        grid.EnableDragGridSize(False)
        grid.SetMargins(0, 0)

        # Columns
        grid.EnableDragColMove(False)
        grid.EnableDragColSize(True)
        grid.SetColLabelSize(0)
        grid.SetColLabelAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)

        # Rows
        grid.EnableDragRowSize(True)
        grid.SetRowLabelSize(0)
        grid.SetRowLabelAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)

        # Label Appearance

        # Cell Defaults
        grid.SetDefaultCellBackgroundColour(wx.Colour(255, 255, 255))
        grid.SetDefaultCellAlignment(wx.ALIGN_LEFT, wx.ALIGN_TOP)

        # Set Cell Values
        grid.SetCellValue(0, 0, " Variable")
        grid.SetCellValue(1, 0, " Name")
        grid.SetCellValue(2, 0, " Description")
        grid.SetCellValue(3, 0, " Unit")
        grid.SetCellValue(4, 0, " Name")
        grid.SetCellValue(5, 0, " Type")
        grid.SetCellValue(6, 0, " Abbreviation")

        grid.SetCellBackgroundColour(0, 0, wx.Colour(195, 195, 195))
        grid.SetCellBackgroundColour(0, 1, wx.Colour(195, 195, 195))
        grid.SetCellBackgroundColour(3, 0, wx.Colour(195, 195, 195))
        grid.SetCellBackgroundColour(3, 1, wx.Colour(195, 195, 195))
        grid.SetGridLineColour(wx.Colour(195, 195, 195))
        self.resize_grid_to_fill_white_space(grid)
Exemplo n.º 16
0
    def _updateColAttrs(self, grid, row=None):
        """
        wx.Grid -> update the column attributes to add the
        appropriate renderer given the column name.

        Otherwise default to the default renderer.
        """

        for row in range(self.GetNumberRows()):
            for col in range(self.GetNumberCols()):
                editor = None
                renderer = None
                readonly = False
                colname = self.GetColLabelValue(col, False)
                if colname == "Qualifier":
                    editor = wx.grid.GridCellChoiceEditor(
                        self.Parent.QualifierList.split(','))
                    editor.SetParameters(self.Parent.QualifierList)
                if colname == "Duration":
                    editor = wx.grid.GridCellTextEditor()
                    renderer = wx.grid.GridCellStringRenderer()
                    readonly = not self.Parent.DurationList[
                        self.data[row].qualifier]
                elif colname == "Type":
                    editor = wx.grid.GridCellChoiceEditor(GetTypeList())
                    editor.SetParameters(self.Parent.TypeList)
                elif colname == "Value":
                    value_type = self.data[row].type
                    if value_type == "Action":
                        editor = wx.grid.GridCellChoiceEditor(
                            self.Parent.ActionList.split(','))
                        editor.SetParameters(self.Parent.ActionList)
                    elif value_type == "Variable":
                        editor = wx.grid.GridCellChoiceEditor(
                            self.Parent.VariableList.split('1'))
                        editor.SetParameters(self.Parent.VariableList)
                    elif value_type == "Inline":
                        editor = wx.grid.GridCellTextEditor()
                        renderer = wx.grid.GridCellStringRenderer()
                elif colname == "Indicator":
                    editor = wx.grid.GridCellChoiceEditor(
                        self.Parent.VariableList.split(','))
                    editor.SetParameters(self.Parent.VariableList)

                grid.SetCellEditor(row, col, editor)
                grid.SetCellRenderer(row, col, renderer)
                grid.SetReadOnly(row, col, readonly)

                grid.SetCellBackgroundColour(row, col, wx.WHITE)
            self.ResizeRow(grid, row)
Exemplo n.º 17
0
    def RemoveHighlight(self, grid, infos, highlight_type):
        row = infos[0]
        for col in range(self.GetNumberCols()):
            # grid.SetReadOnly(row, col, True)
            # grid.SetCellEditor(row, col, None)
            # grid.SetCellRenderer(row, col, None)

            highlight_colours = (wx.WHITE, wx.BLACK)
            grid.SetCellBackgroundColour(row, col, highlight_colours[0])
            grid.SetCellTextColour(row, col, highlight_colours[1])
        grid.ForceRefresh()
        row_highlights = self.Highlights.get(infos[0])
        if row_highlights is not None:
            col_highlights = row_highlights.get(infos[1])
            if col_highlights is not None and highlight_type in col_highlights:
                col_highlights.remove(highlight_type)
            if col_highlights is not None and len(col_highlights) == 0:
                row_highlights.pop(infos[1])
Exemplo n.º 18
0
    def AddHighlight(self, grid, infos, highlight_type):
        row_highlights = self.Highlights.setdefault(infos[0], {})
        col_highlights = row_highlights.setdefault(infos[1], [])
        col_highlights.append(highlight_type)
        for row in self.Highlights.keys():
            row_highlights = self.Highlights.get(row, {})
            for col in range(self.GetNumberCols()):
                colname = self.GetColLabelValue(col, False)

                # grid.SetReadOnly(row, col, True)
                # grid.SetCellEditor(row, col, None)
                # grid.SetCellRenderer(row, col, None)

                highlight_colours = row_highlights.get(
                    colname.lower(), [(wx.WHITE, wx.BLACK)])[-1]
                grid.SetCellBackgroundColour(row, col, highlight_colours[0])
                grid.SetCellTextColour(row, col, highlight_colours[1])
            self.ResizeRow(grid, row)
        grid.ForceRefresh()
Exemplo n.º 19
0
    def __init__(self):
        wx.Frame.__init__(self, None, title="Grid Attributes", size=(600, 300))
        grid = wx.grid.Grid(self)
        grid.CreateGrid(10, 6)
        for row in range(10):
            for col in range(6):
                grid.SetCellValue(row, col, "(%s,%s)" % (row, col))

        grid.SetCellTextColour(1, 1, "red")
        grid.SetCellFont(1, 1, wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD))
        grid.SetCellBackgroundColour(2, 2, "light blue")

        attr = wx.grid.GridCellAttr()
        attr.SetTextColour("navyblue")
        attr.SetBackgroundColour("pink")
        attr.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD))

        grid.SetAttr(4, 0, attr)
        grid.SetAttr(5, 1, attr)
        grid.SetRowAttr(8, attr)
Exemplo n.º 20
0
    def __init__(self, parent, id, G):
        wx.Frame.__init__(self, parent, id, 'Breadboard', size=(1194, 250))
        grid = wx.grid.Grid(self)
        grid.CreateGrid(10, 64)
        grid.SetRowLabelSize(22)
        grid.SetColMinimalAcceptableWidth(10)
        for row in range(10):
            t1 = chr(row + 97)
            grid.SetRowLabelValue(row, t1)
            for col in range(64):
                t2 = str(col + 1)
                t = t1 + t2
                grid.SetColLabelValue(col, t2)
                grid.SetColSize(col, 18)
                grid.SetCellValue(row, col, t)
                grid.SetCellBackgroundColour(row, col, wx.CYAN)
                grid.SetReadOnly(row, col, isReadOnly=True)
        print "Right click where you want to start."

        grid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnCellLeftClick)

        print G
Exemplo n.º 21
0
    def __init__(self, parent):
        wx.Frame.__init__(self, parent)
        self.create_widgets()
        # Create a wxGrid object
        grid = wx.grid.Grid(self, -1)
        gridPanel = wx.Panel(self, 43, wx.DefaultPosition, wx.Size(300, 200))
        vbox = wx.BoxSizer()
        vbox.Add(grid, 0, wx.ALIGN_CENTER)
        vbox.Add(self.einlese_Button, 0, wx.BOTTOM)
        gridPanel.SetSizer(vbox)
        # Then we call CreateGrid to set the dimensions of the grid
        # (100 rows and 10 columns in this example)
        grid.CreateGrid(20, 10)

        # We can set the sizes of individual rows and columns
        # in pixels
        grid.SetRowSize(0, 60)
        grid.SetColSize(0, 120)

        # And set grid cell contents as strings
        grid.SetCellValue(0, 0, 'wxGrid is good')

        # We can specify that some cells are read.only
        grid.SetCellValue(0, 3, 'This is read.only')
        grid.SetReadOnly(0, 3)

        # Colours can be specified for grid cell contents
        grid.SetCellValue(3, 3, 'green on grey')
        grid.SetCellTextColour(3, 3, wx.GREEN)
        grid.SetCellBackgroundColour(3, 3, wx.LIGHT_GREY)

        # We can specify the some cells will store numeric
        # values rather than strings. Here we set grid column 5
        # to hold floating point values displayed with width of 6
        # and precision of 2
        grid.SetColFormatFloat(5, 6, 2)
        grid.SetCellValue(0, 6, '3.1415')
        self.Show()
Exemplo n.º 22
0
    def _updateColAttrs(self, grid):
        """
        wxGrid -> update the column attributes to add the
        appropriate renderer given the column name.

        Otherwise default to the default renderer.
        """

        for row in range(self.GetNumberRows()):
            for col in range(self.GetNumberCols()):
                editor = None
                renderer = None
                colname = self.GetColLabelValue(col, False)

                editortype = self.columnTypes.get(colname, None)
                if editortype is not None:
                    editor = editortype(self, row, col)

                grid.SetCellEditor(row, col, editor)
                grid.SetCellRenderer(row, col, renderer)

                grid.SetCellBackgroundColour(row, col, wx.WHITE)
            self.ResizeRow(grid, row)
Exemplo n.º 23
0
def onRightClickGridPopupMenu(event,grid,variableObj,currentCellRow,currentCellCol):
    if(grid.GetCellBackgroundColour(currentCellRow,currentCellCol) == variableObj.constantObj.COLOR_EXPORTED):
        grid.SetCellBackgroundColour(currentCellRow,currentCellCol,variableObj.constantObj.COLOR_FILLED_CELL)
    else:
        grid.SetCellBackgroundColour(currentCellRow,currentCellCol,variableObj.constantObj.COLOR_EXPORTED)
Exemplo n.º 24
0
def changeAutoGeneratedTextColor(grid,cellAddress,variableObj):
    row,col = addressExcelToWxpythonFormat(cellAddress)                        #converting address from "A1" format to "0,0"
    if(grid.GetCellBackgroundColour(row,col) != variableObj.constantObj.COLOR_EXPORTED):                  # checking if the cell is not exported
        grid.SetCellBackgroundColour(row,col,variableObj.constantObj.COLOR_AUTOGENERATED)
Exemplo n.º 25
0
def putValueInGridCell(grid,row,col,stringValue,color):
    grid.SetCellValue(row,col,stringValue)
    grid.SetCellBackgroundColour(row,col,color)
Exemplo n.º 26
0
def putStoreFormulaAndValue(grid,variableObj,gridIndex,row,col,newFormulaEvaluatedValue,currentFormula):
    variableObj.formulas[gridIndex][addressWxpythonToExcelFormat(row,col)] = currentFormula      #putting formula into the formulaVariable
    grid.SetCellValue(row,col,newFormulaEvaluatedValue)                    # putting formula evaluated value into grid cell
    if(grid.GetCellBackgroundColour(row,col) != variableObj.constantObj.COLOR_EXPORTED  ):
        grid.SetCellBackgroundColour(row,col,variableObj.constantObj.COLOR_AUTOGENERATED)
Exemplo n.º 27
0
    def _updateColAttrs(self, grid):
        """
        wx.grid.Grid -> update the column attributes to add the
        appropriate renderer given the column name.

        Otherwise default to the default renderer.
        """
        
        for col in range(self.GetNumberCols()):
            attr = wx.grid.GridCellAttr()
            attr.SetAlignment(ColAlignements[col], wx.ALIGN_CENTRE)
            grid.SetColAttr(col, attr)
            grid.SetColMinimalWidth(col, ColSizes[col])
            grid.AutoSizeColumn(col, False)
        
        typelist = None
        maplist = None
        for row in range(self.GetNumberRows()):
            editors = self.editors[row]
            if wx.Platform == '__WXMSW__':
                grid.SetRowMinimalHeight(row, 20)
            else:
                grid.SetRowMinimalHeight(row, 28)
            grid.AutoSizeRow(row, False)
            for col in range(self.GetNumberCols()):
                editor = None
                renderer = None
                
                colname = self.GetColLabelValue(col, False)
                editortype = editors[colname]
                if editortype == "dcf":
                    editor = wx.grid.GridCellTextEditor()
                    renderer = wx.grid.GridCellStringRenderer()
                elif editortype and self.Editable:
                    grid.SetReadOnly(row, col, False)
                    if editortype == "string":
                        editor = wx.grid.GridCellTextEditor()
                        renderer = wx.grid.GridCellStringRenderer()
                        if colname == "value" and "length" in editors:
                            editor.SetParameters(editors["length"]) 
                    elif editortype == "number":
                        editor = wx.grid.GridCellNumberEditor()
                        renderer = wx.grid.GridCellNumberRenderer()
                        if colname == "value" and "min" in editors and "max" in editors:
                            editor.SetParameters("%s,%s"%(editors["min"],editors["max"]))
                    elif editortype == "float":
                        editor = wx.grid.GridCellTextEditor()
                        renderer = wx.grid.GridCellStringRenderer()
                    elif editortype == "bool":
                        editor = wx.grid.GridCellBoolEditor()
                        # editor.SetParameters(BoolList)
                    elif editortype == "access":
                        editor = wx.grid.GridCellChoiceEditor(AccessList, False)
                        # editor.SetParameters(AccessList)
                    elif editortype == "raccess":
                        editor = wx.grid.GridCellChoiceEditor(RAccessList, False)
                        # editor.SetParameters(RAccessList)
                    elif editortype == "option":
                        editor = wx.grid.GridCellChoiceEditor(OptionList, False)
                        # editor.SetParameters(OptionList)
                    elif editortype == "type":
                        if typelist == None:
                            typelist = self.Parent.Manager.GetCurrentTypeList()
                        editor = wx.grid.GridCellChoiceEditor(typelist.split(","))
                        # editor.SetParameters(typelist)
                    elif editortype == "map":
                        if maplist == None:
                            maplist = self.Parent.Manager.GetCurrentMapList()
                        editor = wx.grid.GridCellChoiceEditor(maplist.split(","))    
                        # editor.SetParameters(maplist)
                    elif editortype == "time":
                        editor = wx.grid.GridCellTextEditor()
                        renderer = wx.grid.GridCellStringRenderer()
                    elif editortype == "domain":
                        editor = wx.grid.GridCellTextEditor()
                        renderer = wx.grid.GridCellStringRenderer()
                else:
                    grid.SetReadOnly(row, col, True)
                    
                grid.SetCellEditor(row, col, editor)
                grid.SetCellRenderer(row, col, renderer)
                
                grid.SetCellBackgroundColour(row, col, wx.WHITE)
Exemplo n.º 28
0
def formulaEntryIsTextOnly(grid,variableObj,gridIndex,row,col,currentFormula):
    variableObj.formulas[gridIndex][addressWxpythonToExcelFormat(row,col)] = currentFormula
    grid.SetCellValue(row,col,currentFormula[1:])
    grid.SetCellBackgroundColour(row,col,variableObj.constantObj.COLOR_FILLED_CELL)
Exemplo n.º 29
0
    def _updateColAttrs(self, grid):
        """
        wx.grid.Grid -> update the column attributes to add the
        appropriate renderer given the column name.

        Otherwise default to the default renderer.
        """
        for row in range(self.GetNumberRows()):
            var_class = self.GetValueByName(row, "Class")
            var_type = self.GetValueByName(row, "Type")
            row_highlights = self.Highlights.get(row, {})
            for col in range(self.GetNumberCols()):
                editor = None
                renderer = None
                colname = self.GetColLabelValue(col, False)
                if self.Parent.Debug:
                    grid.SetReadOnly(row, col, True)
                else:
                    if colname == "Option":
                        options = GetOptions(
                            constant=var_class
                            in ["Local", "External", "Global"],
                            retain=self.Parent.ElementType != "function"
                            and var_class
                            in ["Local", "Input", "Output", "Global"],
                            non_retain=self.Parent.ElementType != "function"
                            and var_class in ["Local", "Input", "Output"])
                        if len(options) > 1:
                            editor = wx.grid.GridCellChoiceEditor()
                            editor.SetParameters(",".join(map(_, options)))
                        else:
                            grid.SetReadOnly(row, col, True)
                    elif col != 0 and self.GetValueByName(row, "Edit"):
                        grid.SetReadOnly(row, col, False)
                        if colname == "Name":
                            editor = wx.grid.GridCellTextEditor()
                            renderer = wx.grid.GridCellStringRenderer()
                        elif colname == "Initial Value":
                            if var_class not in ["External", "InOut"]:
                                if self.Parent.Controler.IsEnumeratedType(
                                        var_type):
                                    editor = wx.grid.GridCellChoiceEditor()
                                    editor.SetParameters(",".join(
                                        self.Parent.Controler.
                                        GetEnumeratedDataValues(var_type)))
                                else:
                                    editor = wx.grid.GridCellTextEditor()
                                renderer = wx.grid.GridCellStringRenderer()
                            else:
                                grid.SetReadOnly(row, col, True)
                        elif colname == "Location":
                            if var_class in [
                                    "Local", "Global"
                            ] and self.Parent.Controler.IsLocatableType(
                                    var_type):
                                editor = LocationCellEditor(
                                    self, self.Parent.Controler)
                                renderer = wx.grid.GridCellStringRenderer()
                            else:
                                grid.SetReadOnly(row, col, True)
                        elif colname == "Class":
                            if len(self.Parent.ClassList) == 1:
                                grid.SetReadOnly(row, col, True)
                            else:
                                editor = wx.grid.GridCellChoiceEditor()
                                excluded = []
                                if self.Parent.IsFunctionBlockType(var_type):
                                    excluded.extend(["Local", "Temp"])
                                editor.SetParameters(",".join([
                                    _(choice)
                                    for choice in self.Parent.ClassList
                                    if choice not in excluded
                                ]))
                    elif colname != "Documentation":
                        grid.SetReadOnly(row, col, True)

                grid.SetCellEditor(row, col, editor)
                grid.SetCellRenderer(row, col, renderer)

                if colname == "Location" and LOCATION_MODEL.match(
                        self.GetValueByName(row, colname)) is None:
                    highlight_colours = ERROR_HIGHLIGHT
                else:
                    highlight_colours = row_highlights.get(
                        colname.lower(), [(wx.WHITE, wx.BLACK)])[-1]
                grid.SetCellBackgroundColour(row, col, highlight_colours[0])
                grid.SetCellTextColour(row, col, highlight_colours[1])
            self.ResizeRow(grid, row)
Exemplo n.º 30
0
    def _updateColAttrs(self, grid, row=None):
        """
        wx.grid.Grid -> update the column attributes to add the
        appropriate renderer given the column name.

        Otherwise default to the default renderer.
        """

        for col in range(self.GetNumberCols()):
            attr = wx.grid.GridCellAttr()
            attr.SetAlignment(self.ColAlignements[col], wx.ALIGN_CENTRE)
            grid.SetColAttr(col, attr)
            grid.SetColSize(col, self.ColSizes[col])

        for row in range(self.GetNumberRows()):
            row_highlights = self.Highlights.get(row, {})
            for col in range(self.GetNumberCols()):
                editor = None
                renderer = None
                error = False
                colname = self.GetColLabelValue(col, False)
                grid.SetReadOnly(row, col, False)
                if colname == "Name":
                    editor = wx.grid.GridCellTextEditor()
                    renderer = wx.grid.GridCellStringRenderer()
                elif colname == "Interval":
                    editor = DurationCellEditor(self, colname)
                    renderer = wx.grid.GridCellStringRenderer()
                    if self.GetValueByName(row, "Triggering") != "Cyclic":
                        grid.SetReadOnly(row, col, True)
                    interval = self.GetValueByName(row, colname)
                    if interval != "" and IEC_TIME_MODEL.match(
                            interval.upper()) is None:
                        error = True
                elif colname == "Single":
                    editor = SingleCellEditor(self, colname)
                    editor.SetParameters(self.Parent.VariableList)
                    if self.GetValueByName(row, "Triggering") != "Interrupt":
                        grid.SetReadOnly(row, col, True)
                    single = self.GetValueByName(row, colname)
                    if single != "" and not CheckSingle(
                            single, self.Parent.VariableList):
                        error = True
                elif colname == "Triggering":
                    editor = wx.grid.GridCellChoiceEditor(
                        GetTaskTriggeringOptions())
                    editor.SetParameters(",".join(
                        map(_, GetTaskTriggeringOptions())))
                elif colname == "Type":
                    editor = wx.grid.GridCellChoiceEditor(
                        self.Parent.TypeList.split(','))
                    # editor.SetParameters(self.Parent.TypeList)
                elif colname == "Priority":
                    editor = wx.grid.GridCellNumberEditor()
                    editor.SetParameters("0,65535")
                elif colname == "Task":
                    editor = wx.grid.GridCellChoiceEditor(
                        self.Parent.TaskList.split(','))
                    # editor.SetParameters(self.Parent.TaskList)

                if editor:
                    editor.IncRef()
                    grid.SetCellEditor(row, col, editor)
                grid.SetCellRenderer(row, col, renderer)

                if error:
                    highlight_colours = ERROR_HIGHLIGHT
                else:
                    highlight_colours = row_highlights.get(
                        colname.lower(), [(wx.WHITE, wx.BLACK)])[-1]
                grid.SetCellBackgroundColour(row, col, highlight_colours[0])
                grid.SetCellTextColour(row, col, highlight_colours[1])
            self.ResizeRow(grid, row)