implemented rename and remove functions
This commit is contained in:
parent
77d3e86827
commit
f36dc353df
4 changed files with 45 additions and 10 deletions
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
// "python.pythonPath": "/home/lynne/Projects/code/python/buypeeb/venv/bin/python3.8"
|
||||
}
|
29
buypeeb.py
29
buypeeb.py
|
@ -71,6 +71,7 @@ class BuypeebApp:
|
|||
self.window = None
|
||||
self.settings = BuypeebSettings(settingsLocation)
|
||||
self.builder = None
|
||||
self.selected = None
|
||||
|
||||
def run(self, argv):
|
||||
self.app.run(argv)
|
||||
|
@ -88,6 +89,7 @@ class BuypeebApp:
|
|||
self.setExchangeRate()
|
||||
|
||||
self.settings.load()
|
||||
self.resetSidePane()
|
||||
self.renderList()
|
||||
|
||||
def activate(self, app):
|
||||
|
@ -192,6 +194,12 @@ class BuypeebApp:
|
|||
for label, contents in info.items():
|
||||
self.builder.get_object(f"lblSelected{label}").set_label(contents)
|
||||
|
||||
def resetSidePane(self):
|
||||
for label in ["YahooName", "Price", "PriceAUD", "Ending", "Bids"]:
|
||||
self.builder.get_object(f"lblSelected{label}").set_label("")
|
||||
|
||||
self.builder.get_object("lblSelectedName").set_label("buypeeb")
|
||||
|
||||
|
||||
# BUTTON CLICKS
|
||||
|
||||
|
@ -199,7 +207,7 @@ class BuypeebApp:
|
|||
url = self.entryBox("Add URL", "Enter the URL of the item you want to add.")
|
||||
if url:
|
||||
# vry simpl url validation for simpol creachers
|
||||
if functions.rmatch(r"https?.+yahoo.+", url):
|
||||
if functions.rmatch(r"http.+yahoo.+", url):
|
||||
self.settings.watch(url)
|
||||
else:
|
||||
self.msgBox("Invalid URL", "The provided URL was invalid.", Gtk.MessageType.ERROR)
|
||||
|
@ -231,15 +239,32 @@ class BuypeebApp:
|
|||
|
||||
prompt.format_secondary_text("Are you sure you want to quit buypeeb?")
|
||||
response = prompt.run()
|
||||
if response:
|
||||
if response == Gtk.ResponseType.OK:
|
||||
self.shutdown(self)
|
||||
|
||||
def btnSelectedRenameClicked(self, widget):
|
||||
item = self.settings.watchlist[self.selected]
|
||||
name = self.entryBox("Rename", f"Enter a new name for \"{item.name}\".")
|
||||
if name:
|
||||
item.name = name
|
||||
|
||||
self.renderList() # TODO: only update the changed item
|
||||
|
||||
def btnSelectedRemoveClicked(self, widget):
|
||||
del self.settings.watchlist[self.selected]
|
||||
self.selected = None
|
||||
self.renderList()
|
||||
self.resetSidePane()
|
||||
|
||||
# OTHER UI INTERACTIONS
|
||||
|
||||
def tveItemsSelectionChanged(self, selection):
|
||||
items, treeIter = selection.get_selected()
|
||||
if treeIter == None:
|
||||
return
|
||||
row = items[treeIter]
|
||||
id = row[3]
|
||||
self.selected = id
|
||||
self.updateSidePane(id)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -345,7 +345,7 @@
|
|||
<object class="GtkLabel" id="lblSelectedName">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">buypeeb</property>
|
||||
<property name="label" translatable="yes">precious peebus polytonal player</property>
|
||||
<property name="justify">center</property>
|
||||
<property name="wrap">True</property>
|
||||
<property name="ellipsize">end</property>
|
||||
|
@ -446,6 +446,7 @@
|
|||
<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>
|
||||
|
@ -458,6 +459,7 @@
|
|||
<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>
|
||||
|
@ -469,6 +471,7 @@
|
|||
<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>
|
||||
|
@ -480,6 +483,7 @@
|
|||
<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,6 +495,7 @@
|
|||
<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>
|
||||
|
@ -597,11 +602,12 @@
|
|||
<property name="homogeneous">True</property>
|
||||
<property name="layout_style">expand</property>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<object class="GtkButton" id="btnSelectedRemove">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="tooltip_text" translatable="yes">Delete</property>
|
||||
<property name="tooltip_text" translatable="yes">Remove</property>
|
||||
<signal name="clicked" handler="btnSelectedRemoveClicked" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkImage" id="image4">
|
||||
<property name="visible">True</property>
|
||||
|
@ -618,11 +624,12 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<object class="GtkButton" id="btnSelectedRename">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="tooltip_text" translatable="yes">Rename</property>
|
||||
<signal name="clicked" handler="btnSelectedRenameClicked" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkImage" id="image1">
|
||||
<property name="visible">True</property>
|
||||
|
@ -638,7 +645,7 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<object class="GtkButton" id="btnSelectedUpdate">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
|
@ -658,7 +665,7 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToggleButton">
|
||||
<object class="GtkToggleButton" id="btnSelectedFavourite">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
|
|
Loading…
Reference in a new issue