千城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 全志H618ROM新增分区
  • ¥20 jupyter保存图像功能的实现
  • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示
  • ¥15 NAO机器人的录音程序保存问题
  • ¥15 C#读写EXCEL文件,不同编译
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键
  • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符
  • ¥15 NX MCD仿真与博途通讯不了啥情况