[Tkinter-discuss] ttk.Spinbox missing?

Mark Summerfield list at qtrac.plus.com
Wed Jun 13 14:55:36 CEST 2012


Hi Michael,

On Wed, 13 Jun 2012 14:12:10 +0200
Michael Lange <klappnase at web.de> wrote:
[snip]
> I don't know who currently maintains Tkinter and how much time they have
> to work on it, maybe it would help if someone wrote a patch.
> >From a quick glance I think the spinbox might not require any more code
> than the following snippet:
> 
> #################################################################
> import ttk
> 
> class Spinbox(ttk.Entry):
> 
>     def __init__(self, master=None, **kw):
>         ttk.Entry.__init__(self, master, "ttk::spinbox", **kw)
> 
>     def current(self, newindex=None):
>         return self.tk.call(self._w, 'current', index)
> 
>     def set(self, value):
>         return self.tk.call(self._w, 'set', value)
> #################################################################
> 
> Can you store this to a file spinbox.py and then import the spinbox
> widget from there and test if everything works? Maybe there still needs
> some tweaking to be done to make all configuration options work properly
> (as in ttk.Combobox).

I didn't check "everything", but I tried it and it worked. I respects
the from and to values (when using the up and down arrows or the up and
down arrow keys), but just like tk.Spinbox allows you to type in any old
junk.

-- 
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
    C++, Python, Qt, PyQt - training and consultancy
        "Programming in Python 3" - ISBN 0321680561
            http://www.qtrac.eu/py3book.html


More information about the Tkinter-discuss mailing list