-2

These are my imports.

import tkinter as tk
from tkinter import ttk
from tkinter import Menu
from tkinter import messagebox as msg

The code:

window = tk.Tk()
window.title('TITLE')

spin = Spinbox(window, from_ = 0, to = 99, width = 5, bd = 8)
spin.grid(column = 0, row = 3)

window.mainloop()

If I use ttk, Spinbox will be defined, but bd doesn't work either which doesn't make sense for me.


import tkinter as tk
from tkinter import ttk
from tkinter import Menu
from tkinter import messagebox as msg

window = tk.Tk()

spin = ttk.Spinbox(window, from_ = 0, to = 99, width = 5, bd = 8)
spin.grid(row = 0, column = 3)

window.mainloop()

This is the way I tried to solve it. But, "bd" wasn't defined.

Nameless
  • 383
  • 2
  • 11

1 Answers1

1

When using the

import tkinter as tk

import style, you need to use tk in front of all imported names:

import tkinter as tk

window = tk.Tk()
window.title('TITLE')

spin = tk.Spinbox(window, from_ = 0, to = 99, width = 5, bd = 8)
spin.grid(column = 0, row = 3)

window.mainloop()
Novel
  • 13,406
  • 2
  • 25
  • 41
  • Why not ttk? Thank you. – Nameless Nov 15 '20 at 00:14
  • You can use ttk.Spinbox, but all ttk widgets use the ttk.Style() to set the appearance, not arguments like tk widgets do. https://docs.python.org/3/library/tkinter.ttk.html#ttk-styling – Novel Nov 15 '20 at 00:31