now you can select items to view info about them

This commit is contained in:
Lynne Megido 2020-08-23 22:17:33 +10:00
parent 42bed9b175
commit 77d3e86827
Signed by: lynnesbian
GPG key ID: F0A184B5213D9F90
4 changed files with 42 additions and 11 deletions

View file

@ -21,11 +21,13 @@
import requests, gi import requests, gi
gi.require_version('Gtk', '3.0') gi.require_version('Gtk', '3.0')
from gi.repository import Gtk from gi.repository import Gtk
from pebble import ProcessPool
import json, sys import json, sys
from os import path from os import path
from threading import Thread from threading import Thread
from datetime import datetime from datetime import datetime
from concurrent.futures import TimeoutError
import functions import functions
from listing import YahooAuctionsItem, JST from listing import YahooAuctionsItem, JST
@ -151,12 +153,15 @@ class BuypeebApp:
def renderList(self): def renderList(self):
self.items.clear() self.items.clear()
print(self.settings.watchlist) # print(self.settings.watchlist)
for id, item in self.settings.watchlist.items(): for id, item in self.settings.watchlist.items():
if item.ready: if item.ready:
self.items.append([item.name, item.price_aud(self.rate), "...", id]) self.items.append([item.name, item.price_aud(self.rate), "...", id])
else: else:
self.items.append([item.name, "...", "...", id]) name = item.name
if name == None:
name = "Loading..."
self.items.append([name, "...", "...", id])
self.updateListTimes() self.updateListTimes()
@ -173,6 +178,21 @@ class BuypeebApp:
else: else:
listing[2] = f"{idate} {itime}" listing[2] = f"{idate} {itime}"
def updateSidePane(self, id: str):
item = self.settings.watchlist[id]
info = {
"Name": item.name,
"YahooName": item.original_name,
"Price": item.price_jpy(),
"PriceAUD": item.price_aud(),
"Ending": item.ending_in(),
"Bids": item.bids
}
for label, contents in info.items():
self.builder.get_object(f"lblSelected{label}").set_label(contents)
# BUTTON CLICKS # BUTTON CLICKS
def btnAddClicked(self, widget): def btnAddClicked(self, widget):
@ -214,6 +234,14 @@ class BuypeebApp:
if response: if response:
self.shutdown(self) self.shutdown(self)
# OTHER UI INTERACTIONS
def tveItemsSelectionChanged(self, selection):
items, treeIter = selection.get_selected()
row = items[treeIter]
id = row[3]
self.updateSidePane(id)
if __name__ == '__main__': if __name__ == '__main__':
app = BuypeebApp() app = BuypeebApp()
app.run(sys.argv) app.run(sys.argv)

View file

@ -86,8 +86,8 @@ class YahooAuctionsItem:
# the good news is, yahoo japan returns all the data we need in handy json format # the good news is, yahoo japan returns all the data we need in handy json format
# the bad news is that the only way to get that json format is to download the whole auction page and grep it # the bad news is that the only way to get that json format is to download the whole auction page and grep it
r = requests.get(f"https://page.auctions.yahoo.co.jp/jp/auction/{self.id}").text # r = requests.get(f"https://page.auctions.yahoo.co.jp/jp/auction/{self.id}").text
# r = open("yahoo.html").read() r = open("yahoo.html").read()
j = json.loads(re.match(r'.*var pageData ?= ?(\{.*?\});', r, re.DOTALL).group(1)) j = json.loads(re.match(r'.*var pageData ?= ?(\{.*?\});', r, re.DOTALL).group(1))
except: except:
raise raise
@ -110,3 +110,6 @@ class YahooAuctionsItem:
def price_aud(self, rate = 75.0): def price_aud(self, rate = 75.0):
return f"${self.price / rate:.2f}" return f"${self.price / rate:.2f}"
def ending_in(self):
return "heenlo"

View file

@ -1,2 +1,3 @@
requests==2.24 requests==2.24
PyGObject==3.36 PyGObject==3.36
pebble==4.5

View file

@ -275,7 +275,9 @@
<property name="search_column">1</property> <property name="search_column">1</property>
<property name="activate_on_single_click">True</property> <property name="activate_on_single_click">True</property>
<child internal-child="selection"> <child internal-child="selection">
<object class="GtkTreeSelection"/> <object class="GtkTreeSelection">
<signal name="changed" handler="tveItemsSelectionChanged" swapped="no"/>
</object>
</child> </child>
<child> <child>
<object class="GtkTreeViewColumn"> <object class="GtkTreeViewColumn">
@ -343,10 +345,12 @@
<object class="GtkLabel" id="lblSelectedName"> <object class="GtkLabel" id="lblSelectedName">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label" translatable="yes">precious peebus polytonal player</property> <property name="label" translatable="yes">buypeeb</property>
<property name="justify">center</property> <property name="justify">center</property>
<property name="wrap">True</property> <property name="wrap">True</property>
<property name="ellipsize">end</property>
<property name="max_width_chars">40</property> <property name="max_width_chars">40</property>
<property name="lines">3</property>
<attributes> <attributes>
<attribute name="weight" value="bold"/> <attribute name="weight" value="bold"/>
<attribute name="scale" value="2"/> <attribute name="scale" value="2"/>
@ -442,7 +446,6 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="halign">end</property> <property name="halign">end</property>
<property name="label" translatable="yes">something in japanese</property>
<property name="ellipsize">end</property> <property name="ellipsize">end</property>
</object> </object>
<packing> <packing>
@ -455,7 +458,6 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="halign">end</property> <property name="halign">end</property>
<property name="label" translatable="yes">¥12345</property>
</object> </object>
<packing> <packing>
<property name="left_attach">2</property> <property name="left_attach">2</property>
@ -467,7 +469,6 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="halign">end</property> <property name="halign">end</property>
<property name="label" translatable="yes">$123.45</property>
</object> </object>
<packing> <packing>
<property name="left_attach">2</property> <property name="left_attach">2</property>
@ -479,7 +480,6 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="halign">end</property> <property name="halign">end</property>
<property name="label" translatable="yes">1h 17m 23s</property>
</object> </object>
<packing> <packing>
<property name="left_attach">2</property> <property name="left_attach">2</property>
@ -491,7 +491,6 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="halign">end</property> <property name="halign">end</property>
<property name="label" translatable="yes">5</property>
</object> </object>
<packing> <packing>
<property name="left_attach">2</property> <property name="left_attach">2</property>