Changeset 152
- Timestamp:
- 04/20/08 21:26:48 (3 months ago)
- Files:
-
- sucrose/trunk/python/api/sucrose.py (modified) (1 diff)
- sucrose/trunk/python/keypad_tk.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sucrose/trunk/python/api/sucrose.py
r146 r152 36 36 37 37 def recent_purchases_for_user(self, user): 38 transactions = self.transactions.filter_by(user _id=user.uid).\38 transactions = self.transactions.filter_by(user=user).\ 39 39 order_by(self.db.Transaction.transaction_id.desc()).\ 40 40 limit(5).all() 41 41 42 42 return [(t.item_name, t.cost) for t in transactions] 43 44 def total_spent_by_user(self, user): 45 return self.transactions.filter_by(user=user).\ 46 sum(self.db.Transaction.cost) 43 47 44 48 def vend(self, tray, uin): sucrose/trunk/python/keypad_tk.py
r151 r152 167 167 168 168 offset = row + 3 169 for row, (name, price) in enumerate(purchases):170 Tkinter.Label(self, text=name, font= ('helvetica', 13),171 anchor=Tkinter.W, justify=Tkinter.LEFT, wraplength=200,172 bg='white').grid(row=offset + row, column=0, columnspan=3,173 sticky=Tkinter.EW)174 Tkinter.Label(self, text='$%.2f' % price, font= ('helvetica', 13),169 def price_row(row, name, price, font=('helvetica', 13)): 170 Tkinter.Label(self, text=name, font=font, anchor=Tkinter.W, 171 justify=Tkinter.LEFT, wraplength=200, bg='white').\ 172 grid(row=offset + row, column=0, columnspan=3, 173 sticky=Tkinter.EW) 174 Tkinter.Label(self, text='$%.2f' % price, font=font, 175 175 anchor=Tkinter.NE, justify=Tkinter.RIGHT, 176 176 bg='white').grid(row=offset + row, column=3, 177 177 sticky=Tkinter.NSEW) 178 179 for row, (name, price) in enumerate(purchases): 180 price_row(row, name, price) 181 price_row(row + 1, 'Total Spent', 182 self.sucrose.total_spent_by_user(self.user), 183 font=('helvetica', 13, 'bold')) 184 178 185 # } END statistics GUI 179 186
