Added mana icon files, limit search results to 50, improved caching
2
gui.py
@@ -34,7 +34,7 @@ class MainWindow(Gtk.Window):
|
||||
|
||||
win = MainWindow()
|
||||
# Load local image Data
|
||||
util.imagecache = util.reload_image_cache()
|
||||
util.reload_image_cache()
|
||||
win.connect('delete-event', Gtk.main_quit)
|
||||
win.show_all()
|
||||
Gtk.main()
|
||||
|
||||
BIN
resources/mana_icons/0.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
resources/mana_icons/1.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
resources/mana_icons/10.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
resources/mana_icons/11.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
resources/mana_icons/12.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
resources/mana_icons/13.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
resources/mana_icons/14.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
resources/mana_icons/15.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
resources/mana_icons/16.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
resources/mana_icons/17.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
resources/mana_icons/18.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
resources/mana_icons/19.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
resources/mana_icons/2.png
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
resources/mana_icons/20.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
resources/mana_icons/2b.png
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
resources/mana_icons/2g.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
resources/mana_icons/2r.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
resources/mana_icons/2u.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
resources/mana_icons/2w.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
resources/mana_icons/3.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
resources/mana_icons/4.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
resources/mana_icons/5.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
resources/mana_icons/6.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
resources/mana_icons/7.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
resources/mana_icons/8.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
resources/mana_icons/9.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
resources/mana_icons/b.png
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
BIN
resources/mana_icons/bg.png
Normal file
|
After Width: | Height: | Size: 5.5 KiB |
BIN
resources/mana_icons/bp.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
resources/mana_icons/br.png
Normal file
|
After Width: | Height: | Size: 5.9 KiB |
BIN
resources/mana_icons/flip.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
resources/mana_icons/g.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
resources/mana_icons/gp.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
resources/mana_icons/gu.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
resources/mana_icons/gw.png
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
resources/mana_icons/half.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
resources/mana_icons/infinite.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
resources/mana_icons/r.png
Normal file
|
After Width: | Height: | Size: 6.1 KiB |
BIN
resources/mana_icons/rg.png
Normal file
|
After Width: | Height: | Size: 5.5 KiB |
BIN
resources/mana_icons/rp.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
resources/mana_icons/rw.png
Normal file
|
After Width: | Height: | Size: 6.1 KiB |
BIN
resources/mana_icons/s.png
Normal file
|
After Width: | Height: | Size: 8.3 KiB |
BIN
resources/mana_icons/tap.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
resources/mana_icons/tap_old.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
resources/mana_icons/u.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
resources/mana_icons/ub.png
Normal file
|
After Width: | Height: | Size: 5.0 KiB |
BIN
resources/mana_icons/untap.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
resources/mana_icons/up.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
resources/mana_icons/ur.png
Normal file
|
After Width: | Height: | Size: 5.0 KiB |
BIN
resources/mana_icons/w.png
Normal file
|
After Width: | Height: | Size: 7.5 KiB |
BIN
resources/mana_icons/wb.png
Normal file
|
After Width: | Height: | Size: 6.0 KiB |
BIN
resources/mana_icons/wp.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
resources/mana_icons/wu.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
resources/mana_icons/x.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
resources/mana_icons/y.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
resources/mana_icons/z.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
18
search.py
@@ -36,7 +36,7 @@ class SearchView(Gtk.Grid):
|
||||
self.searchresults = Gtk.ScrolledWindow(hexpand=True, vexpand=True)
|
||||
self.searchresults.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
|
||||
|
||||
self.store = Gtk.ListStore(GdkPixbuf.Pixbuf, str, str)
|
||||
self.store = Gtk.ListStore(GdkPixbuf.Pixbuf, str, str, str)
|
||||
self.list = Gtk.TreeView(self.store)
|
||||
self.searchresults.add(self.list)
|
||||
|
||||
@@ -50,18 +50,23 @@ class SearchView(Gtk.Grid):
|
||||
info.set_property("wrap-width", 100)
|
||||
info.set_padding = 2
|
||||
|
||||
manacost = Gtk.CellRendererText()
|
||||
|
||||
self.column1 = Gtk.TreeViewColumn(title="Image", cell_renderer=image, pixbuf=0)
|
||||
self.column2 = Gtk.TreeViewColumn(title="Card Name", cell_renderer=title, text=1)
|
||||
self.column3 = Gtk.TreeViewColumn(title="Card Text", cell_renderer=info, text=2)
|
||||
self.column4 = Gtk.TreeViewColumn(title="Mana Cost", cell_renderer=manacost, text=3)
|
||||
self.column3.set_max_width(100)
|
||||
|
||||
self.column1.pack_start(image, True)
|
||||
self.column2.pack_start(title, True)
|
||||
self.column3.pack_start(info, True)
|
||||
self.column4.pack_start(manacost, True)
|
||||
|
||||
self.list.append_column(self.column1)
|
||||
self.list.append_column(self.column2)
|
||||
self.list.append_column(self.column3)
|
||||
self.list.append_column(self.column4)
|
||||
|
||||
# Bring it all together
|
||||
self.attach(self.searchbox, 0, 0, 1, 1)
|
||||
@@ -73,14 +78,17 @@ class SearchView(Gtk.Grid):
|
||||
if not term == "":
|
||||
print("Search for \"" + term + "\" online.")
|
||||
|
||||
cards = Card.where(name=term).all()
|
||||
cards = Card.where(name=term).where(pageSize=50).where(page=1).all()
|
||||
self.store.clear()
|
||||
for card in cards:
|
||||
if card.multiverse_id is not None:
|
||||
print("Found ID: " + card.multiverse_id.__str__() + " | " + card.name)
|
||||
print("Found: " + card.name
|
||||
+ " (" + card.multiverse_id.__str__() + ")")
|
||||
self.store.append([util.load_card_image(card),
|
||||
card.name,
|
||||
card.original_text])
|
||||
card.name,
|
||||
card.original_text,
|
||||
card.mana_cost])
|
||||
|
||||
util.reload_image_cache()
|
||||
|
||||
|
||||
|
||||
5
util.py
@@ -18,11 +18,10 @@ def reload_image_cache():
|
||||
|
||||
# return array of images
|
||||
imageslist = os.listdir(config.cachepath)
|
||||
loadedimages = []
|
||||
imagecache.clear()
|
||||
for image in imageslist:
|
||||
img = PImage.open(config.cachepath + image)
|
||||
loadedimages.append(img)
|
||||
return loadedimages
|
||||
imagecache.append(img)
|
||||
|
||||
|
||||
def add_test_image():
|
||||
|
||||