I am trying to create ttk.Spinbox from tkinter.Spinbox . I can manipulate the codes below, like the ttk.Scrollbar template. The tkinter.Spinbox button gives an old look at my GUI, so I want ttk.Spinbox .
Edit: I am using Python 3.4 for Windows 7. I need a Spinbox theme widget. ttk.__init__ file does not have a Spinbox class / module. So, I open this file and write the codes in the same way as the Scrollbar class specified below.
class Scrollbar(Widget, tkinter.Scrollbar): """Ttk Scrollbar controls the viewport of a scrollable widget.""" def __init__(self, master=None, **kw): """Construct a Ttk Scrollbar with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS command, orient """ Widget.__init__(self, master, "ttk::scrollbar", kw)
And the codes that I put in the ttk.__init__.py file. It inherits from tkinter.Spinbox .
class Spinbox(Widget, tkinter.Spinbox): """spinbox widget.""" def __init__(self, master=None, **kw): Widget.__init__(self, master, "ttk::spinbox", kw)
The test result below is satisfactory. But there is an indentation of the contents of the Spinbox Widget
tkinter.Spinbox Widget 
ttk.Spinbox Widget 
Is there something wrong? Why does indentation occur?
import tkinter as tk import tkinter.ttk as ttk class Spinbox(ttk.Widget): def __init__(self, master, **kw): ttk.Widget.__init__(self, master, 'ttk::spinbox', kw) if __name__ == '__main__': root = tk.Tk() root.grid_columnconfigure(0, weight=1) opts = { 'from_': 5, 'to': 10, 'increment': 1 } sp1 = tk.Spinbox(root, from_=5, to=10) sp1.grid(row=0, column=0) sp2 = Spinbox(root, from_=5, to=10) sp2.grid(row=1, column=0, columnspan=2, sticky="we",pady=2) root.mainloop()
If you expand the root window, then ttk.Spinbox distributed with it and indented. I assume this is due to columnconfigure , but I need a configuration for a better view.