def __build_table(self, issue_refs, issue_ref_hint, enter_button): """ Builds and returns the table for this form. If a good issue key hint is given, that issue will be preselected in the table if possible. 'issue_refs' -> a list with one IssueRef object for each row in the table 'issue_ref_hint' -> may be the issue key for the given book (or may not!) 'enter_button' -> the button to "press" if the user hits enter """ # 1. --- configure the table itself table = ButtonDataGridView(enter_button) table.SortCompare += self.__sort_compare_fired table.AllowUserToOrderColumns = True table.SelectionMode = DataGridViewSelectionMode.FullRowSelect table.MultiSelect = False table.ReadOnly = True table.RowHeadersVisible = False table.AllowUserToAddRows = False table.AllowUserToResizeRows = False table.AllowUserToResizeColumns = False table.DefaultCellStyle.NullValue = "--" table.AutoResizeColumns if self.__config.show_covers_b: table.Size = Size(500, 290) table.Location = Point(218, 60) else: table.Size = Size(708, 290) table.Location = Point(10, 60) # 2. --- build columns table.ColumnCount = 4 table.Columns[0].Name = i18n.get("IssueFormIssueCol") table.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter table.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells table.Columns[1].Name = i18n.get("IssueFormTitleCol") table.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft table.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill table.Columns[2].Name = "ID" table.Columns[2].Visible = False table.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter table.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells table.Columns[3].Name = "Model ID" table.Columns[3].Visible = False table.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter table.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells # 3. --- copy model data into the table, each issue is a row for i in range(len(issue_refs)): title_s = issue_refs[i].title_s key = issue_refs[i].issue_key issue_num_s = issue_refs[i].issue_num_s table.Rows.Add() table.Rows[i].Cells[0].Value = issue_num_s if issue_num_s else "" table.Rows[i].Cells[1].Value = " " + title_s if title_s else "" table.Rows[i].Cells[2].Value = key table.Rows[i].Cells[3].Value = i # 4. --- sort on the "Issue" column, and then preselect a row based on # the give issue ID hint, or at least the first row if nothing else table.Sort(table.Columns[0], ListSortDirection.Ascending) if issue_ref_hint: for i in range(len(issue_refs)): if table.Rows[i].Cells[2].Value == issue_ref_hint.issue_key: table.CurrentCell = table.Rows[i].Cells[0] self.__found_issue_in_table = True break if not self.__found_issue_in_table: table.CurrentCell = table.Rows[0].Cells[0] table.SelectionChanged += self.__change_table_selection_fired return table
def __build_table(self, issue_refs, issue_ref_hint, enter_button): ''' Builds and returns the table for this form. If a good issue key hint is given, that issue will be preselected in the table if possible. 'issue_refs' -> a list with one IssueRef object for each row in the table 'issue_ref_hint' -> may be the issue key for the given book (or may not!) 'enter_button' -> the button to "press" if the user hits enter ''' # 1. --- configure the table itself table = ButtonDataGridView(enter_button) table.SortCompare += self.__sort_compare_fired table.AllowUserToOrderColumns = True table.SelectionMode = DataGridViewSelectionMode.FullRowSelect table.MultiSelect = False table.ReadOnly = True table.RowHeadersVisible = False table.AllowUserToAddRows = False table.AllowUserToResizeRows = False table.AllowUserToResizeColumns = False table.DefaultCellStyle.NullValue = "--" if self.__config.show_covers_b: table.Size = Size(500, 290) table.Location = Point(218, 60) else: table.Size = Size(708, 290) table.Location = Point(10, 60) # 2. --- build columns table.ColumnCount = 4 table.Columns[0].Name = i18n.get("IssueFormIssueCol") table.Columns[0].DefaultCellStyle.Alignment =\ DataGridViewContentAlignment.MiddleCenter table.Columns[0].AutoSizeMode = \ DataGridViewAutoSizeColumnMode.AllCells table.Columns[1].Name = i18n.get("IssueFormTitleCol") table.Columns[1].DefaultCellStyle.Alignment =\ DataGridViewContentAlignment.MiddleLeft table.Columns[1].AutoSizeMode = \ DataGridViewAutoSizeColumnMode.Fill table.Columns[2].Name = "ID" table.Columns[2].Visible = False table.Columns[2].DefaultCellStyle.Alignment =\ DataGridViewContentAlignment.MiddleCenter table.Columns[2].AutoSizeMode = \ DataGridViewAutoSizeColumnMode.AllCells table.Columns[3].Name = "Model ID" table.Columns[3].Visible = False table.Columns[3].DefaultCellStyle.Alignment =\ DataGridViewContentAlignment.MiddleCenter table.Columns[3].AutoSizeMode =\ DataGridViewAutoSizeColumnMode.AllCells # 3. --- copy model data into the table, each issue is a row for i in range(len(issue_refs)): title_s = issue_refs[i].title_s key = issue_refs[i].issue_key issue_num_s = issue_refs[i].issue_num_s table.Rows.Add() table.Rows[i].Cells[0].Value = issue_num_s if issue_num_s else '' table.Rows[i].Cells[1].Value = ' ' + title_s if title_s else '' table.Rows[i].Cells[2].Value = key table.Rows[i].Cells[3].Value = i # 4. --- sort on the "Issue" column, and then preselect a row based on # the give issue ID hint, or at least the first row if nothing else table.Sort(table.Columns[0], ListSortDirection.Ascending) if issue_ref_hint: for i in range(len(issue_refs)): if table.Rows[i].Cells[2].Value == issue_ref_hint.issue_key: table.CurrentCell = table.Rows[i].Cells[0] self.__found_issue_in_table = True break if not self.__found_issue_in_table: table.CurrentCell = table.Rows[0].Cells[0] table.SelectionChanged += self.__change_table_selection_fired return table
def __build_table(self, series_refs, book, enter_button): ''' Builds and returns the table for this form. 'series_refs' -> a list with one SeriesRef object for each found series 'book' -> the ComicBook being scraped 'enter_button' -> the button to "press" if the user hits enter ''' # 1. --- configure the table itself table = ButtonDataGridView(enter_button) table.AllowUserToOrderColumns = True table.SelectionMode = DataGridViewSelectionMode.FullRowSelect table.MultiSelect = False table.ReadOnly = True table.RowHeadersVisible = False table.AllowUserToAddRows = False table.AllowUserToResizeRows = False table.AllowUserToResizeColumns = False table.DefaultCellStyle.NullValue = "--" table.Location = Point(10, 60) table.Size = Size(500, 290) \ if self.__config.show_covers_b else Size(710, 290) # 2. --- build columns table.ColumnCount = 7 table.Columns[0].Name = i18n.get("SeriesFormSeriesCol") table.Columns[0].DefaultCellStyle.Alignment =\ DataGridViewContentAlignment.MiddleLeft table.Columns[0].Resizable = DataGridViewTriState. True table.Columns[0].FillWeight = 200 table.Columns[0].AutoSizeMode = \ DataGridViewAutoSizeColumnMode.Fill table.Columns[1].Name = i18n.get("SeriesFormYearCol") table.Columns[1].DefaultCellStyle.Alignment =\ DataGridViewContentAlignment.MiddleCenter table.Columns[1].Resizable = DataGridViewTriState. True table.Columns[1].AutoSizeMode =\ DataGridViewAutoSizeColumnMode.AllCells table.Columns[2].Name = i18n.get("SeriesFormIssuesCol") table.Columns[2].DefaultCellStyle.Alignment =\ DataGridViewContentAlignment.MiddleCenter table.Columns[2].Resizable = DataGridViewTriState. True table.Columns[2].AutoSizeMode =\ DataGridViewAutoSizeColumnMode.AllCells table.Columns[3].Name = i18n.get("SeriesFormPublisherCol") table.Columns[3].DefaultCellStyle.Alignment =\ DataGridViewContentAlignment.MiddleLeft table.Columns[3].Resizable = DataGridViewTriState. True table.Columns[3].AutoSizeMode =\ DataGridViewAutoSizeColumnMode.Fill table.Columns[4].Name = "ID" table.Columns[4].Visible = False table.Columns[4].DefaultCellStyle.Alignment =\ DataGridViewContentAlignment.MiddleCenter table.Columns[4].AutoSizeMode =\ DataGridViewAutoSizeColumnMode.AllCells table.Columns[5].Name = "Match" table.Columns[5].Visible = False table.Columns[5].DefaultCellStyle.Alignment =\ DataGridViewContentAlignment.MiddleCenter table.Columns[5].AutoSizeMode =\ DataGridViewAutoSizeColumnMode.AllCells table.Columns[6].Name = "Model ID" table.Columns[6].Visible = False table.Columns[6].DefaultCellStyle.Alignment =\ DataGridViewContentAlignment.MiddleCenter table.Columns[6].AutoSizeMode =\ DataGridViewAutoSizeColumnMode.AllCells # 3. --- copy model data into the table, each series is a row for i in range(len(series_refs)): table.Rows.Add() ref = series_refs[i] table.Rows[i].Cells[0].Value = ref.series_name_s if ref.volume_year_n >= 0: table.Rows[i].Cells[1].Value = ref.volume_year_n table.Rows[i].Cells[2].Value = ref.issue_count_n table.Rows[i].Cells[3].Value = ref.publisher_s table.Rows[i].Cells[4].Value = ref.series_key table.Rows[i].Cells[5].Value = self.__matchscore.compute_n( book, ref) table.Rows[i].Cells[6].Value = i # 4. --- sort on the "match" colum table.Sort(table.Columns[5], ListSortDirection.Descending) table.SelectionChanged += self.__change_table_selection_fired return table
def __build_table(self, series_refs, book, enter_button): ''' Builds and returns the table for this form. 'series_refs' -> a list with one SeriesRef object for each found series 'book' -> the ComicBook being scraped 'enter_button' -> the button to "press" if the user hits enter ''' # 1. --- configure the table itself table = ButtonDataGridView(enter_button) table.AllowUserToOrderColumns = True table.SelectionMode = DataGridViewSelectionMode.FullRowSelect table.MultiSelect = False table.ReadOnly = True table.RowHeadersVisible = False table.AllowUserToAddRows = False table.AllowUserToResizeRows = False table.AllowUserToResizeColumns = False table.DefaultCellStyle.NullValue = "--" table.AutoResizeColumns table.Location = Point(10, 60) table.Size = Size(500, 290) \ if self.__config.show_covers_b else Size(710, 290) # 2. --- build columns table.ColumnCount = 7 table.Columns[0].Name = i18n.get("SeriesFormSeriesCol") table.Columns[0].DefaultCellStyle.Alignment =\ DataGridViewContentAlignment.MiddleLeft table.Columns[0].Resizable = DataGridViewTriState.True table.Columns[0].FillWeight = 200 table.Columns[0].AutoSizeMode = \ DataGridViewAutoSizeColumnMode.Fill table.Columns[1].Name = i18n.get("SeriesFormYearCol") table.Columns[1].DefaultCellStyle.Alignment =\ DataGridViewContentAlignment.MiddleCenter table.Columns[1].Resizable = DataGridViewTriState.True table.Columns[1].AutoSizeMode =\ DataGridViewAutoSizeColumnMode.AllCells table.Columns[2].Name = i18n.get("SeriesFormIssuesCol") table.Columns[2].DefaultCellStyle.Alignment =\ DataGridViewContentAlignment.MiddleCenter table.Columns[2].Resizable = DataGridViewTriState.True table.Columns[2].AutoSizeMode =\ DataGridViewAutoSizeColumnMode.AllCells table.Columns[3].Name = i18n.get("SeriesFormPublisherCol") table.Columns[3].DefaultCellStyle.Alignment =\ DataGridViewContentAlignment.MiddleLeft table.Columns[3].Resizable = DataGridViewTriState.True table.Columns[3].AutoSizeMode =\ DataGridViewAutoSizeColumnMode.Fill table.Columns[4].Name = "ID" table.Columns[4].Visible = False table.Columns[4].DefaultCellStyle.Alignment =\ DataGridViewContentAlignment.MiddleCenter table.Columns[4].AutoSizeMode =\ DataGridViewAutoSizeColumnMode.AllCells table.Columns[5].Name = "Match" table.Columns[5].Visible = False table.Columns[5].DefaultCellStyle.Alignment =\ DataGridViewContentAlignment.MiddleCenter table.Columns[5].AutoSizeMode =\ DataGridViewAutoSizeColumnMode.AllCells table.Columns[6].Name = "Model ID" table.Columns[6].Visible = False table.Columns[6].DefaultCellStyle.Alignment =\ DataGridViewContentAlignment.MiddleCenter table.Columns[6].AutoSizeMode =\ DataGridViewAutoSizeColumnMode.AllCells # 3. --- copy model data into the table, each series is a row for i in range(len(series_refs)): table.Rows.Add() ref = series_refs[i] table.Rows[i].Cells[0].Value = ref.series_name_s if ref.volume_year_n >= 0: table.Rows[i].Cells[1].Value = ref.volume_year_n table.Rows[i].Cells[2].Value = ref.issue_count_n table.Rows[i].Cells[3].Value = ref.publisher_s table.Rows[i].Cells[4].Value = ref.series_key table.Rows[i].Cells[5].Value = self.__matchscore.compute_n(book, ref) table.Rows[i].Cells[6].Value = i # 4. --- sort on the "match" colum table.Sort( table.Columns[5], ListSortDirection.Descending ) table.SelectionChanged += self.__change_table_selection_fired return table