diff --git a/collection.py b/collection.py new file mode 100644 index 0000000..7d8dcf3 --- /dev/null +++ b/collection.py @@ -0,0 +1,81 @@ +import gi +from psutil._compat import xrange + +gi.require_version('Gtk', '3.0') +from gi.repository import Gtk, GdkPixbuf + + +class CollectionView(Gtk.Grid): + def __init__(self): + Gtk.Grid.__init__(self) + + # Search Box + self.searchbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2) + self.searchEntry = Gtk.Entry() + self.searchEntryLabel = Gtk.Label("Search in Collection:", xalign=0) + self.searchbox.add(self.searchEntryLabel) + self.searchbox.add(self.searchEntry) + + # Filters + self.filterBox = Gtk.ListBox() + self.filterBox.set_selection_mode(Gtk.SelectionMode.NONE) + + self.testRow = Gtk.ListBoxRow() + hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50) + hbox.add(Gtk.Label("Filters will go here", xalign=0)) + self.testRow.add(hbox) + + self.filterBox.add(self.testRow) + + # The Small Card Flow + self.cardScroller = Gtk.ScrolledWindow(hexpand=True, vexpand=True) + self.cardScroller.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) + + self.cardFlow = Gtk.FlowBox() + self.cardFlow.set_valign(Gtk.Align.START) + self.cardFlow.set_max_children_per_line(50) + self.cardFlow.set_selection_mode(Gtk.SelectionMode.NONE) + self.create_flowbox(self.cardFlow) + self.cardScroller.add(self.cardFlow) + + # Detailed Card View + self.detailBox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2) + + # Big Picture of the selected Card + self.image_area = Gtk.Box() + self.bigCard = Gtk.Image() + self.pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size('./resources/images/demo.jpg', 63 * 4, 88 * 4) + self.bigCard.set_from_pixbuf(self.pixbuf) + self.image_area.add(self.bigCard) + self.detailBox.add(self.image_area) + + # Stats and Details about the selected Card + self.stat_listbox = Gtk.ListBox() + self.stat_listbox.set_selection_mode(Gtk.SelectionMode.NONE) + self.test_statrow = Gtk.ListBoxRow() + hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50) + hbox.add(Gtk.Label("Detail about the selected Card goes here", xalign=0)) + self.test_statrow.add(hbox) + self.stat_listbox.add(self.test_statrow) + + self.detailBox.add(self.stat_listbox) + + + # Bring it all together + self.attach(self.searchbox, 0, 0, 1, 1) + self.attach(self.filterBox, 0, 1, 1, 1) + self.attach(self.cardScroller, 1, 0, 1, 2) + self.attach(self.detailBox, 2, 0, 1, 2) + + def add_test_image(self): + image = Gtk.Image() + pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size('./resources/images/demo.jpg', 63*2, 88*2) + image.set_from_pixbuf(pixbuf) + + return image + + def create_flowbox(self, flowbox): + + for nr in xrange(0, 50): + image = self.add_test_image() + flowbox.add(image) diff --git a/gui.py b/gui.py index 80c1663..87181d0 100644 --- a/gui.py +++ b/gui.py @@ -1,17 +1,21 @@ import gi +import collection + gi.require_version('Gtk', '3.0') from gi.repository import Gtk + class MainWindow(Gtk.Window): def __init__(self): Gtk.Window.__init__(self, title="MTG Collector v0.1") self.set_border_width(2) + self.set_size_request(1000, 700) self.notebook = Gtk.Notebook() self.add(self.notebook) self.collectionView = Gtk.Box() - self.collectionView.add(Gtk.Label("My Magic Card Collection!")) + self.collectionView.add(collection.CollectionView()) self.searchView = Gtk.Box() self.searchView.add(Gtk.Label("Search the whole Magic Card Library!")) @@ -19,7 +23,6 @@ class MainWindow(Gtk.Window): self.deckView = Gtk.Box() self.deckView.add(Gtk.Label("View and organize your Decklists!")) - self.notebook.append_page(self.collectionView, Gtk.Label("Collection")) self.notebook.append_page(self.deckView, Gtk.Label("Decks")) self.notebook.append_page(self.searchView, Gtk.Label("Search")) diff --git a/resources/images/demo.jpg b/resources/images/demo.jpg new file mode 100644 index 0000000..8ee2dbc Binary files /dev/null and b/resources/images/demo.jpg differ