千城hh 2020-07-27 17:41 采纳率: 33.3%
浏览 136
已采纳

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services