Python Forum

Full Version: Problem adding a float to a DoubleVar
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have declared a DoubleVar() as I need to use the variable as a textvariable for a tkinter label. However; when I try to add to it I get the error
Output:
unsupported operand type(s) for +: 'DoubleVar' and 'float'
This code is part of a function:
global dailyTotal
    dailyTotal = dailyTotal + 3.0
And dailyTotal is decalred as a DoubleVar():
dailyTotal = DoubleVar()
    dailyTotalLabel = Label(root, textvariable = dailyTotal)
Use
dailyTotal.set(dailyTotal.get() + 3.0)
(Apr-03-2018, 08:45 AM)Gribouillis Wrote: [ -> ]Use
dailyTotal.set(dailyTotal.get() + 3.0)

Thank you, that did the trick.