]> git.phdru.name Git - m_librarian.git/commitdiff
Feat(wx/books): Display author on a separate row
authorOleg Broytman <phd@phdru.name>
Tue, 9 Jan 2024 01:38:54 +0000 (04:38 +0300)
committerOleg Broytman <phd@phdru.name>
Tue, 9 Jan 2024 13:58:48 +0000 (16:58 +0300)
[skip ci]

m_librarian/wx/ListBooks.py

index 4cfabcdb36026af7206ce0cff6f1c618047df1d0..b027de006e89282b5bf6821979c34b598221c05d 100644 (file)
@@ -16,7 +16,7 @@ class ListBooksPanel(GridPanel):
         for author in books_by_author:
             books = books_by_author[author]
             series = {book.series for book in books}
-            total_rows += len(books) + len(series)
+            total_rows += len(books) + len(series) + 1
         grid = self.grid
         grid.CreateGrid(total_rows, len(columns))
         grid.EnableEditing(False)
@@ -32,6 +32,10 @@ class ListBooksPanel(GridPanel):
                 grid.SetColAttr(col, cell_attr)
         row = 0
         for author in sorted(books_by_author):
+            grid.SetCellAlignment(row, 0, wx.ALIGN_LEFT, wx. ALIGN_CENTRE)
+            grid.SetCellSize(row, 0, 1, len(columns))
+            grid.SetCellValue(row, 0, u'%s' % (author,))
+            row += 1
             books = books_by_author[author]
             series = None
             for book in books:
@@ -40,9 +44,11 @@ class ListBooksPanel(GridPanel):
                         value = book.series
                     else:
                         value = u'Вне серий'
-                    grid.SetCellAlignment(row, 0, wx.ALIGN_LEFT, wx. ALIGN_CENTRE)
+                    grid.SetCellAlignment(row, 0,
+                                          wx.ALIGN_LEFT, wx. ALIGN_CENTRE)
                     grid.SetCellSize(row, 0, 1, len(columns))
-                    grid.SetCellValue(row, 0, u'%s — %s' % (book.author1, value))
+                    grid.SetCellValue(row, 0,
+                                      u'%s — %s' % (book.author1, value))
                     row += 1
                     series = book.series
                 for col, col_name in enumerate(columns):
@@ -65,6 +71,7 @@ class ListBooksPanel(GridPanel):
         else:
             event.Skip()
 
+
 class ListBooksWindow(GridWindow):
 
     session_config_section_name = 'list_books'