class BinChip:
def __init__ (Self,name,capacity,master=None):
Self.capacity = capacity
Self.name = name
Self.percentfull = DoubleVar()
Self.percentfull.set(0.0)
Self.frame = Frame(master, { 'name': name ,
'relief' : 'groove',
'borderwidth' : '1m',
Pack: {'expand': 1, 'fill': 'both'}})
Self.identity = Label (Self.frame,{"text" : name })
Self.identity.pack({'side' : 'top',
'expand': 1, 'fill': 'both'})
Self.canvas = Canvas(Self.frame, { 'name': name ,
'relief' : 'ridge',
Pack: {'expand': 1, 'fill': 'both'},
'bg' : 'white' })
Self.canvas.bind('<Button-1>',Self.errorBinChip)
Self.blacked = Canvas(Self.canvas, { 'name': name ,
# wanted something like this
#'variable' : 'Self.percentfull', Pack: {'expand': 1, 'fill': 'x'},
'bg' : 'black' })
Self.display_howfull()
def display_howfull(Self):
Self.blacked.place( {'relx' : '0.0',
'rely' : `1.0 - Self.percentfull.get()`,
'anchor' : 'nw'})
def resetBinChip (Self):
Self.percentfull.set(0.0)
Self.display_howfull() # don't really want to do this explicitly
def refreshBinChip (Self):
Self.display_howfull()
def fillBinChip (Self, percent):
Self.percentfull.set(percent)
Self.display_howfull()
def incrBinChip (Self, amount):
Self.percentfull.set( Self.percentfull.get() + (amount/Self.capacity))
Self.display_howfull()
def decrBinChip (Self, amount):
Self.percentfull.set( Self.percentfull.get() - (amount/Self.capacity))
Self.display_howfull()
def errorBinChip (Self,event):
inform = ErrorDialog(Self.canvas,' This is not an active object')
inform.Show()
inform.DialogCleanup()
del inform
Ps. as another question when should(?) you use del