名称 'Spinbox' 未定义
name 'Spinbox' is not defined
这些是我的进口商品。
import tkinter as tk
from tkinter import ttk
from tkinter import Menu
from tkinter import messagebox as msg
代码:
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()
如果我使用 ttk,将定义 Spinbox,但 bd 也不起作用,这对我来说没有意义。
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()
这是我尝试解决的方法。但是,没有定义“bd”。
使用时
import tkinter as tk
导入样式,需要在所有导入名称前加上tk
:
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()
这些是我的进口商品。
import tkinter as tk
from tkinter import ttk
from tkinter import Menu
from tkinter import messagebox as msg
代码:
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()
如果我使用 ttk,将定义 Spinbox,但 bd 也不起作用,这对我来说没有意义。
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()
这是我尝试解决的方法。但是,没有定义“bd”。
使用时
import tkinter as tk
导入样式,需要在所有导入名称前加上tk
:
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()