bpo-32585: Add tkinter.ttk.Spinbox. (GH-5221) (GH-5592)
(cherry picked from commit a48e78a0b7761dd74f1d03fc69e0f6caa6f02fe6)
Co-authored-by: Alan D Moore <me@alandmoore.com>
diff --git a/Lib/tkinter/ttk.py b/Lib/tkinter/ttk.py
index e6c90ce..c165115 100644
--- a/Lib/tkinter/ttk.py
+++ b/Lib/tkinter/ttk.py
@@ -19,7 +19,7 @@
__all__ = ["Button", "Checkbutton", "Combobox", "Entry", "Frame", "Label",
"Labelframe", "LabelFrame", "Menubutton", "Notebook", "Panedwindow",
"PanedWindow", "Progressbar", "Radiobutton", "Scale", "Scrollbar",
- "Separator", "Sizegrip", "Style", "Treeview",
+ "Separator", "Sizegrip", "Spinbox", "Style", "Treeview",
# Extensions
"LabeledScale", "OptionMenu",
# functions
@@ -1151,6 +1151,33 @@
Widget.__init__(self, master, "ttk::sizegrip", kw)
+class Spinbox(Entry):
+ """Ttk Spinbox is an Entry with increment and decrement arrows
+
+ It is commonly used for number entry or to select from a list of
+ string values.
+ """
+
+ def __init__(self, master=None, **kw):
+ """Construct a Ttk Spinbox widget with the parent master.
+
+ STANDARD OPTIONS
+
+ class, cursor, style, takefocus, validate,
+ validatecommand, xscrollcommand, invalidcommand
+
+ WIDGET-SPECIFIC OPTIONS
+
+ to, from_, increment, values, wrap, format, command
+ """
+ Entry.__init__(self, master, "ttk::spinbox", **kw)
+
+
+ def set(self, value):
+ """Sets the value of the Spinbox to value."""
+ self.tk.call(self._w, "set", value)
+
+
class Treeview(Widget, tkinter.XView, tkinter.YView):
"""Ttk Treeview widget displays a hierarchical collection of items.