The tkinter version I am using is accessing tk.TclVersion=8.6.
I am able to access stylename='TSpinbox' from ttk.Style()
.
Stylename = TSpinbox
Layout = [('Spinbox.field', {'side': 'top', 'sticky': 'we', 'children': [('null', {'side': 'right', 'sticky': '', 'children': [('Spinbox.uparrow', {'side': 'top', 'sticky': 'e'}), ('Spinbox.downarrow', {'side': 'bottom', 'sticky': 'e'})]}), ('Spinbox.padding', {'sticky': 'nswe', 'children': [('Spinbox.textarea', {'sticky': 'nswe'})]})]})]
Element(s) = ['Spinbox.field', 'null', 'Spinbox.uparrow', 'Spinbox.downarrow', 'Spinbox.padding', 'Spinbox.textarea']
Spinbox.field options: ('fieldbackground', 'borderwidth')
null options: ()
Spinbox.uparrow options: ('background', 'relief', 'borderwidth', 'arrowcolor', 'arrowsize')
Spinbox.downarrow options: ('background', 'relief', 'borderwidth', 'arrowcolor', 'arrowsize')
Spinbox.padding options: ('padding', 'relief', 'shiftrelief')
Spinbox.textarea options: ('font', 'width')
According to documentation , widget ttk.Spinbox
exists. But in Python 3.6.5 tkinter.ttk
, such a widget does not exist:
AttributeError: module 'tkinter.ttk' has no attribute 'Spinbox'
May I know when this widget will be made available or which version of Python tkinter.ttk
already offers the ttk.Spinbox
widget? Thanks.
You're right, the implementation of the ttk Spinbox was omitted. This has been solved for python 3.7 .
You can copy this implementation to do this yourself though:
import tkinter as tk
from tkinter import ttk
class Spinbox(ttk.Entry):
def __init__(self, master=None, **kw):
ttk.Entry.__init__(self, master, "ttk::spinbox", **kw)
def set(self, value):
self.tk.call(self._w, "set", value)
root = tk.Tk()
s = Spinbox(root, from_=0, to=10)
s.set(5)
s.pack()
root.mainloop()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.