now you can select items to view info about them
This commit is contained in:
parent
42bed9b175
commit
77d3e86827
4 changed files with 42 additions and 11 deletions
32
buypeeb.py
32
buypeeb.py
|
@ -21,11 +21,13 @@
|
|||
import requests, gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
from pebble import ProcessPool
|
||||
|
||||
import json, sys
|
||||
from os import path
|
||||
from threading import Thread
|
||||
from datetime import datetime
|
||||
from concurrent.futures import TimeoutError
|
||||
|
||||
import functions
|
||||
from listing import YahooAuctionsItem, JST
|
||||
|
@ -151,12 +153,15 @@ class BuypeebApp:
|
|||
|
||||
def renderList(self):
|
||||
self.items.clear()
|
||||
print(self.settings.watchlist)
|
||||
# print(self.settings.watchlist)
|
||||
for id, item in self.settings.watchlist.items():
|
||||
if item.ready:
|
||||
self.items.append([item.name, item.price_aud(self.rate), "...", id])
|
||||
else:
|
||||
self.items.append([item.name, "...", "...", id])
|
||||
name = item.name
|
||||
if name == None:
|
||||
name = "Loading..."
|
||||
self.items.append([name, "...", "...", id])
|
||||
|
||||
self.updateListTimes()
|
||||
|
||||
|
@ -173,6 +178,21 @@ class BuypeebApp:
|
|||
else:
|
||||
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
|
||||
|
||||
def btnAddClicked(self, widget):
|
||||
|
@ -214,6 +234,14 @@ class BuypeebApp:
|
|||
if response:
|
||||
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__':
|
||||
app = BuypeebApp()
|
||||
app.run(sys.argv)
|
||||
|
|
|
@ -86,8 +86,8 @@ class YahooAuctionsItem:
|
|||
# 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
|
||||
|
||||
r = requests.get(f"https://page.auctions.yahoo.co.jp/jp/auction/{self.id}").text
|
||||
# r = open("yahoo.html").read()
|
||||
# r = requests.get(f"https://page.auctions.yahoo.co.jp/jp/auction/{self.id}").text
|
||||
r = open("yahoo.html").read()
|
||||
j = json.loads(re.match(r'.*var pageData ?= ?(\{.*?\});', r, re.DOTALL).group(1))
|
||||
except:
|
||||
raise
|
||||
|
@ -110,3 +110,6 @@ class YahooAuctionsItem:
|
|||
|
||||
def price_aud(self, rate = 75.0):
|
||||
return f"${self.price / rate:.2f}"
|
||||
|
||||
def ending_in(self):
|
||||
return "heenlo"
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
requests==2.24
|
||||
PyGObject==3.36
|
||||
pebble==4.5
|
||||
|
|
|
@ -275,7 +275,9 @@
|
|||
<property name="search_column">1</property>
|
||||
<property name="activate_on_single_click">True</property>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection"/>
|
||||
<object class="GtkTreeSelection">
|
||||
<signal name="changed" handler="tveItemsSelectionChanged" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn">
|
||||
|
@ -343,10 +345,12 @@
|
|||
<object class="GtkLabel" id="lblSelectedName">
|
||||
<property name="visible">True</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="wrap">True</property>
|
||||
<property name="ellipsize">end</property>
|
||||
<property name="max_width_chars">40</property>
|
||||
<property name="lines">3</property>
|
||||
<attributes>
|
||||
<attribute name="weight" value="bold"/>
|
||||
<attribute name="scale" value="2"/>
|
||||
|
@ -442,7 +446,6 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="label" translatable="yes">something in japanese</property>
|
||||
<property name="ellipsize">end</property>
|
||||
</object>
|
||||
<packing>
|
||||
|
@ -455,7 +458,6 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="label" translatable="yes">¥12345</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">2</property>
|
||||
|
@ -467,7 +469,6 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="label" translatable="yes">$123.45</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">2</property>
|
||||
|
@ -479,7 +480,6 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="label" translatable="yes">1h 17m 23s</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">2</property>
|
||||
|
@ -491,7 +491,6 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="label" translatable="yes">5</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">2</property>
|
||||
|
|
Loading…
Reference in a new issue