def _create_grid ( self, parent, sizer ):
        """ Creates the associated grid control used to implement the table.
        """
        factory        = self.factory
        selection_mode = GridModes[ factory.selection_mode ]
        if factory.selection_bg_color is None:
            selection_mode = ''

        self.grid = grid = Grid( parent,
            model                        = self.model,
            enable_lines                 = factory.show_lines,
            grid_line_color              = factory.line_color,
            show_row_headers             = factory.show_row_labels,
            show_column_headers          = factory.show_column_labels,
            default_cell_font            = factory.cell_font,
            default_cell_text_color      = factory.cell_color,
            default_cell_bg_color        = factory.cell_bg_color,
            default_cell_read_only_color = factory.cell_read_only_bg_color,
            default_label_font           = factory.label_font,
            default_label_text_color     = factory.label_color,
            default_label_bg_color       = factory.label_bg_color,
            selection_bg_color           = factory.selection_bg_color,
            selection_text_color         = factory.selection_color,
            autosize                     = factory.auto_size,
            read_only                    = not factory.editable,
            edit_on_first_click          = factory.edit_on_first_click,
            selection_mode               = selection_mode,
            allow_column_sort            = factory.sortable,
            allow_row_sort               = False,
            column_label_height          = factory.column_label_height,
            row_label_width              = factory.row_label_width
        )
        _grid = grid._grid
        _grid.SetScrollLineY( factory.scroll_dy )

        # Set the default size for each table row:
        height = factory.row_height
        if height <= 0:
            height = _grid.GetTextExtent( 'My' )[1] + 9
        _grid.SetDefaultRowSize( height )

        # Allow the table to be resizable if the user did not explicitly
        # specify a number of rows to display:
        self.scrollable = (factory.rows == 0)

        # Calculate a reasonable default size for the table:
        if len( self.model.get_filtered_items() ) > 0:
            height = _grid.GetRowSize( 0 )

        max_rows = factory.rows or 15

        min_width = max( 150, 80 * len( self.columns ) )

        if factory.show_column_labels:
            min_height = _grid.GetColLabelSize() + (max_rows * height)
        else:
            min_height = (max_rows * height)

        _grid.SetMinSize(wx.Size(min_width, min_height))

        # On Linux, there is what appears to be a bug in wx in which the
        # vertical scrollbar will not be sized properly if the TableEditor is
        # sized to be shorter than the minimum height specified above. Since
        # this height is only set to ensure that the TableEditor is sized
        # correctly during the initial UI layout, we un-set it after this takes
        # place (addresses ticket 1810)
        def clear_minimum_height ( info ):
            min_size = _grid.GetMinSize()
            min_size.height = 0
            _grid.SetMinSize ( min_size )
        self.ui.add_defined ( clear_minimum_height )

        sizer.Add( grid.control, 1, wx.EXPAND )

        return grid.control

    #---------------------------------------------------------------------------
    #  Creates the table editing tool bar:
    #---------------------------------------------------------------------------
dataset/ETHPy150Open enthought/traitsui/traitsui/wx/table_editor.py/TableEditor._create_grid/original