コード例 #1
0
ファイル: unit_renderer.py プロジェクト: sjl421/code-2
    def DrawBackground(self, grid, attr, dc, rect, row, col, isSelected):
        """ Erases whatever is already in the cell by drawing over it.
        """
        # We have to set the clipping region on the grid's DC,
        # otherwise the text will spill over to the next cell
        dc.SetClippingRect(rect)

        # overwrite anything currently in the cell ...
        dc.SetBackgroundMode(wx.SOLID)

        dc.SetPen(wx.Pen(wx.WHITE, 1, wx.SOLID))

        text = grid.model.GetValue(row, col)
        if unit_parser:
            this_unit = unit_parser.parse_unit(text, self.suppress_warnings)
        else:
            this_unit = None

        # Todo - clean up this hardcoded logic/column position mess

        family = grid.model.GetValue(row, 6)

        # AI units of 'impedance ((kg/s)*(g/cc))' creates list of 3, not 2!
        try:
            family, other_text = family[:-1].split('(')
        except:
            family, other_text = family[:-1].split(' ')

        if unit_parser:
            other_unit = unit_parser.parse_unit(other_text,
                                                self.suppress_warnings)
            dimensionally_equivalent = this_unit.can_convert(other_unit)
        else:
            other_unit = None
            dimensionally_equivalent = False

        if isSelected:
            dc.SetBrush(DefaultRenderer.selected_cells)
        elif not this_unit or not this_unit.is_valid():
            dc.SetBrush(DefaultRenderer.error_cells)
        elif not dimensionally_equivalent:
            dc.SetBrush(DefaultRenderer.warn_cells)
        else:
            dc.SetBrush(DefaultRenderer.normal_cells)

        dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height)
        return
コード例 #2
0
ファイル: unit_renderer.py プロジェクト: fspaolo/code
    def DrawBackground(self, grid, attr, dc, rect, row, col, isSelected):
        """ Erases whatever is already in the cell by drawing over it.
        """
        # We have to set the clipping region on the grid's DC,
        # otherwise the text will spill over to the next cell
        dc.SetClippingRect(rect)

        # overwrite anything currently in the cell ...
        dc.SetBackgroundMode(wx.SOLID)

        dc.SetPen(wx.Pen(wx.WHITE, 1, wx.SOLID))

        text = grid.model.GetValue(row, col)
        if unit_parser:
            this_unit = unit_parser.parse_unit(text, self.suppress_warnings)
        else:
            this_unit = None

        # Todo - clean up this hardcoded logic/column position mess

        family = grid.model.GetValue(row, 6)

        # AI units of 'impedance ((kg/s)*(g/cc))' creates list of 3, not 2!
        try:
            family, other_text = family[:-1].split('(')
        except:
            family, other_text = family[:-1].split(' ')

        if unit_parser:
            other_unit = unit_parser.parse_unit(other_text, self.suppress_warnings)
            dimensionally_equivalent = this_unit.can_convert(other_unit)
        else:
            other_unit = None
            dimensionally_equivalent = False

        if isSelected:
            dc.SetBrush(DefaultRenderer.selected_cells)
        elif not this_unit or not this_unit.is_valid():
            dc.SetBrush(DefaultRenderer.error_cells)
        elif not dimensionally_equivalent:
            dc.SetBrush(DefaultRenderer.warn_cells)
        else:
            dc.SetBrush(DefaultRenderer.normal_cells)

        dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height)
        return
コード例 #3
0
ファイル: unit_renderer.py プロジェクト: sjl421/code-2
    def DrawBackground(self, grid, attr, dc, rect, row, col, isSelected):
        """ Erases whatever is already in the cell by drawing over it.
        """
        # We have to set the clipping region on the grid's DC,
        # otherwise the text will spill over to the next cell
        dc.SetClippingRect(rect)

        # overwrite anything currently in the cell ...
        dc.SetBackgroundMode(wx.SOLID)

        dc.SetPen(wx.Pen(wx.WHITE, 1, wx.SOLID))

        text = grid.model.GetValue(row, col)

        if isSelected:
            dc.SetBrush(DefaultRenderer.selected_cells)
        elif unit_parser and unit_parser.parse_unit(text).is_valid():
            dc.SetBrush(DefaultRenderer.normal_cells)
        else:
            dc.SetBrush(DefaultRenderer.error_cells)

        dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height)
        return
コード例 #4
0
ファイル: unit_renderer.py プロジェクト: fspaolo/code
    def DrawBackground(self, grid, attr, dc, rect, row, col, isSelected):
        """ Erases whatever is already in the cell by drawing over it.
        """
        # We have to set the clipping region on the grid's DC,
        # otherwise the text will spill over to the next cell
        dc.SetClippingRect(rect)

        # overwrite anything currently in the cell ...
        dc.SetBackgroundMode(wx.SOLID)

        dc.SetPen(wx.Pen(wx.WHITE, 1, wx.SOLID))

        text = grid.model.GetValue(row, col)

        if isSelected:
            dc.SetBrush(DefaultRenderer.selected_cells)
        elif unit_parser and unit_parser.parse_unit(text).is_valid():
            dc.SetBrush(DefaultRenderer.normal_cells)
        else:
            dc.SetBrush(DefaultRenderer.error_cells)

        dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height)
        return