Auction clock As part of a game, I simulated an auction clock, like used in flower auctions, with the help of python and the GUI Tkinter.
Getting Started
The auctionclock can be runned with the following function. AuctionClock.AC(root, startingBid, auctioneer, bidders, imageFile)
The root is has to be generated by Tkinter. The startingBid is an integer. The auctioneer is a Player instance in AuctionClock and the bidders are a list of Player instances. The imageFile is a file containing a picture.
auctioneer = AuctionClock.player(name) bidders = [AuctionClock.Player(name), AuctionClock.Player(name), … enz]
The name is a String. Here, some examples are shown to make an auctioneer and the bidders. You can decide to participate by choosing player for yourself. This player will not controlled by the computer. This player must be part of the list containing the bidders to participate. You must use the name of the player to select.
AuctionClock.choosePlayer(bidders, name)
There is a button in the auction to participate you have to click the shown button. After the auction you can retrieve the name and the bid amount of the highest bidder:
print clock.bidAmount highestBidder = AuctionClock.giveHighestBidder(clock, bidders) print highestBidder.name
Prerequisites You need the library Tkinter to make the auction clock. Here is an example of code which runs with Tkinter.
from Tkinter import * root = Tk() auctioneer = AuctionClock.Player("Machteld") bidders = [AuctionClock.Player("Johannes"), AuctionClock.Player("Pieter"), AuctionClock.Player("Maria")] AuctionClock.choosePlayer(bidders, "Johannes") AuctionClock.RunAC(root, 100, auctioneer, bidders, "fleur.jpg") root.destroy() root.mainloop()