best way to increment an IntVar?

rantingrick rantingrick at gmail.com
Thu Jun 24 01:26:53 EDT 2010


On Jun 24, 12:07 am, Ben Finney <ben+pyt... at benfinney.id.au> wrote:
> Alan G Isaac <alan.is... at gmail.com> writes:
>
> > Of course one can do
> >    myintvar.set(myintvar.get()+1)
> > but surely there is a better way?
>
> What is an IntVar? It's not a built-in type, so you'll need to tell us.

For those who don't know; IntVar is from the module Tkinter. It is a
class to contain an integer control var used to update Tkinter widgets
that support it.

@OP: No there is not an __iadd__ method in the IntVar class but if you
really, really want to update this way just subclass IntVar and create
the method yourself. OOP is cool like dat!

You can also configure a Tkiter widget via the Python syntax w[key] =
value OR w.config(key1=value1, key2=value2, ...)





More information about the Python-list mailing list