Skip to content

Commit abbe723

Browse files
committed
Add scrollbar to watchlist frame
1 parent 59a1280 commit abbe723

1 file changed

Lines changed: 34 additions & 26 deletions

File tree

frames/misc/auctions.py

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import tkinter as tk
12
import tkinter.ttk as ttk
23
from enum import Enum
34

@@ -15,64 +16,71 @@ class Auctions():
1516
cards = {}
1617

1718
def __init__(self, frame):
18-
t = ttk.Treeview(frame, columns=('timestamp', 'initial', 'current', 'bin', 'expires'), selectmode='browse')
19-
t.column("#0", width=75)
20-
t.column("timestamp", width=100)
21-
t.column("initial", width=50)
22-
t.column("current", width=50)
23-
t.column("bin", width=50)
24-
t.column("expires", width=50)
19+
self.view = tk.Frame(frame)
20+
self.view.grid_rowconfigure(0, weight=1)
21+
self.view.grid_columnconfigure(0, weight=1)
22+
self.view.grid_columnconfigure(1, weight=0)
2523

26-
t.heading("#0", text="Name", anchor="w")
27-
t.heading("timestamp", text="Time")
28-
t.heading("initial", text="Initial Bid")
29-
t.heading("current", text="Current Bid")
30-
t.heading("bin", text="BIN")
31-
t.heading("expires", text="Expires")
24+
self.tree = ttk.Treeview(self.view, columns=('timestamp', 'initial', 'current', 'bin', 'expires'))
25+
self.tree.column("#0", width=75)
26+
self.tree.column("timestamp", width=100)
27+
self.tree.column("initial", width=50)
28+
self.tree.column("current", width=50)
29+
self.tree.column("bin", width=50)
30+
self.tree.column("expires", width=50)
3231

33-
t.tag_configure('won', foreground='#006400', background='grey')
34-
t.tag_configure('bid', foreground='#006400')
35-
t.tag_configure('war', foreground='#B77600')
36-
t.tag_configure('sold', foreground='#1C7CA9', background='grey')
37-
t.tag_configure('lost', foreground='#B70000', background='grey')
32+
self.tree.heading("#0", text="Name", anchor="w")
33+
self.tree.heading("timestamp", text="Time")
34+
self.tree.heading("initial", text="Initial Bid")
35+
self.tree.heading("current", text="Current Bid")
36+
self.tree.heading("bin", text="BIN")
37+
self.tree.heading("expires", text="Expires")
3838

39-
self.view = t
39+
self.tree.tag_configure('won', foreground='#006400', background='grey')
40+
self.tree.tag_configure('bid', foreground='#006400')
41+
self.tree.tag_configure('war', foreground='#B77600')
42+
self.tree.tag_configure('sold', foreground='#1C7CA9', background='grey')
43+
self.tree.tag_configure('lost', foreground='#B70000', background='grey')
44+
45+
# scrollbar
46+
ysb = ttk.Scrollbar(self.view, orient='vertical', command=self.tree.yview)
47+
self.tree.configure(yscroll=ysb.set)
48+
self.tree.grid(row=0, column=0, sticky='news')
49+
ysb.grid(row=0, column=1, sticky='ns')
4050

4151
def get_view(self):
4252
return self.view
4353

4454
def add_auction(self, card, timestamp, currbid, index='end', tag=''):
4555
if not card.cardid in self.cards:
4656
self.cards[card.cardid] = card
47-
return self.view.insert("", index, card.cardid, text=card.cardname, values=(timestamp, card.startingBid,
57+
return self.tree.insert("", index, card.cardid, text=card.cardname, values=(timestamp, card.startingBid,
4858
currbid, card.buyNowPrice,
4959
card.expires), tags=(tag,))
5060

5161
def update_status(self, card, timestamp, currbid, tag=''):
5262
if not card.cardid in self.cards:
5363
self.add_auction(card, timestamp, currbid, 'end', tag)
5464
else:
55-
options = self.view.item(card.cardid)
65+
options = self.tree.item(card.cardid)
5666
options['values'] = (timestamp, card.startingBid,
5767
currbid, card.buyNowPrice,
5868
card.expires)
5969
if tag:
6070
options['tags'] = (tag,)
61-
self.view.item(card.cardid, text=options['text'], values=options['values'], tags=options['tags'])
62-
self.view.see(card.cardid)
63-
self.view.selection_set([card.cardid])
71+
self.tree.item(card.cardid, text=options['text'], values=options['values'], tags=options['tags'])
72+
self.tree.see(card.cardid)
73+
self.tree.selection_set([card.cardid])
6474

6575
class Card():
6676

6777
def __init__(self, item):
6878
self.cardid = item['id']
6979
self.resourceId = item['resourceId']
7080
self.tradeId = item['tradeId']
71-
self.cardType = item['itemType']
7281
self.buyNowPrice = item['buyNowPrice'] if item['buyNowPrice'] is not None else item['lastSalePrice']
7382
self.startingBid = item['startingBid'] if item['startingBid'] is not None else "BIN"
7483
self.currentBid = item['currentBid'] if item['currentBid'] is not None else item['lastSalePrice']
75-
self.contract = item['contract']
7684
self.expires = item['expires'] if item['expires'] is not None else -1
7785

7886
class PlayerCard(Card):

0 commit comments

Comments
 (0)