各位帮帮忙吧,为什么显示不了项目名称?
from tkinter import * #导入tkinter库
from tkinter import messagebox as ms
import time as t #导入time库
def new_prog(): #定义‘新建项目’函数
global dstr
window2 = Toplevel()
window2.geometry('210x100+320+100')
window2.attributes("-topmost", True) #位于最上层
window2.resizable(height=False, width=False) #大小不可调
window2.title('选项') #设置标题
dstr = StringVar()
Label(window2, text='项目名称', width=6).place(x=18, y=5)
Entry(window2, width=10, textvariable=dstr).place(x=5, y=25)
def click_yes():
window2.destroy()
label1 = Label(window, text=dstr, width=8,font=('kaiti', 18, 'bold'))
label1.place(x=100, y=90)
#window.update()
def click_no(): #定义‘取消’按钮函数
window2.destroy()
Label(window2, text='小时', width=6).place(x=100, y=5)
Spinbox(window2, from_=0, to=23, width=5, wrap=True).place(x=100, y=25)
Label(window2, text='分钟', width=6).place(x=150, y=5)
Spinbox(window2, from_=0, to=59, width=5, wrap=True).place(x=150, y=25)
Button(window2, text='确定', width=6, command=click_yes).place(x=50, y=70)
Button(window2, text='取消', width=6, command=click_no).place(x=110, y=70)
window2.mainloop
return
def config():
def clickyes():
window3.destroy()
def clickno():
window3.destroy()
def a1():
window.attributes("-alpha", 0.2)
def a2():
window.attributes("-alpha", 0.4)
def a3():
window.attributes("-alpha", 0.5)
def a4():
window.attributes("-alpha", 0.6)
def a5():
window.attributes("-alpha", 0.8)
def a6():
window.attributes("-alpha", 1)
window3 = Tk()
window3.geometry('310x200+320+50')
window3.title('设置')
window3.attributes("-topmost", True)
window3.resizable(height=False, width=False)
Label(window3, text='透明度(%)', width=10).place(x=5, y=5)
Radiobutton(window3, text='20%', value=0, command=a1).place(x=0, y=30)
Radiobutton(window3, text='40%', value=1, command=a2).place(x=50, y=30)
Radiobutton(window3, text='50%', value=2, command=a3).place(x=100, y=30)
Radiobutton(window3, text='60%', value=3, command=a4).place(x=150, y=30)
Radiobutton(window3, text='80%', value=4, command=a5).place(x=200, y=30)
Radiobutton(window3, text='100%', value=5, command=a6).place(x=250, y=30)
Button(window3, text='确定', width=8, command=clickyes).place(x=80, y=170)
Button(window3, text='取消', width=8, command=clickno).place(x=155, y=170)
window3.mainloop
window = Tk()
window.geometry('300x300+0+0')
window.title('时间管理器')
window.attributes("-alpha", 1)
window.attributes("-topmost", True)
window.resizable(height=False, width=False)
Button(window, text='新建项目', width=10, command=new_prog).place(x=0, y=50)
Button(window, text='设置', width=10, command=config).place(x=220, y=50)
Label(window,text='当前任务:',width=8,font=('kaiti', 16, 'bold')).place(x=0,y=90)
label2=Label(window,text=t.strftime('%H:%M:%S',t.localtime(t.time())),font=('huawenxihei', 28, 'bold'))
label2.pack(anchor=N)
def trickit():
currentTime=t.strftime('%H:%M:%S',t.localtime(t.time()))
label2.config(text=currentTime)
window.update()
label2.after(1000, trickit)
label2.after(1000, trickit)
window.mainloop()