千城hh
2020-07-27 17:41
采纳率: 66.7%
浏览 108

sbx.set(secs)那里显示'NoneType' object has no attribute 'set',为什么不能用?

bfb = 0
class shezhiThread (threading.Thread):
    def __init__(self):
        threading.Thread.__init__(self)
    def run(self):
        shezhichuangkou()

def shezhichuangkou():
    window = tkinter.Tk()
    window.title("设置")
    window.geometry("300x200")
    window.resizable(width=False, height=False)

    global secs

    l2=tkinter.Label(window, width=15,text="壁纸占屏幕大小",anchor="w").place(x=75, y=100, anchor='sw')
    sbx=tkinter.Spinbox(window, from_=0, to=1, increment=0.1,width=5).place(x=175, y=100, anchor='sw')
    sbx.set(secs)
    bn=tkinter.Button(window,text="确定",width=10,command=lambda:shezhipzwj()).place(x=100, y=150, anchor='sw')

    window.mainloop()

def shezhipzwj():
    cf = configparser.ConfigParser()
    cf.read("config.ini")
    secs = cf.get("shezhi", "bfb")
    global bfb
    print(bfb)

def shezhi(self): 
    thread2 = shezhiThread()
    thread2.start()

sbx.set(secs)那里显示'NoneType' object has no attribute 'set',但是明明有set这个函数,为什么不能用,有大佬看看咋办吗

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • threenewbee 2020-07-27 19:37
    已采纳
    v = StringVar()
    sb = Spinbox(root,
                 values = (0,2,20,40,-1),
                 increment = 2,
                 textvariable = v
                 )
    v.set(20)
    

    不是直接set spinbox

    已采纳该答案
    打赏 评论

相关推荐 更多相似问题