源代码如下fromtkinterimport*importtimeimportthreadingimportosimportos.pathglobalpath_okpath_ok=Falsedefsethighcolor():text1.tag_add("tag_highcolor",SEL_FIRST,SEL_LAST)tex...
源代码如下
from tkinter import *
import time
import threading
import os
import os.path
global path_ok
path_ok=False
def sethighcolor():
text1.tag_add("tag_highcolor",SEL_FIRST,SEL_LAST)
text.tag_config("tag_highcolor",background="yellow")
def ok():
global text1
text1=Text(root,highlightcolor="black",highlightthickness=1).place(relwidth=1,relheight=0.9,relx=0,rely=0.099)
button2=Button(root,text="高亮",command=sethighcolor).place(relx=0,rely=0,relwidth=0.1,relheight=0.099)
def path():
path=dir_path.get()
if path=="D盘":
path="D:\\"
os.mkdir("D:\\fvz_study")
elif path=="C盘":
path="C:\\"
os.mkdir("C:\\fvz_study") #print(path)
path_ok=True
if path_ok==True:
th3=threading.Thread(target=ok,args=())
th3.setDaemon(True)
th3.start()
def FVZ_win():
path_ok=False
time.sleep(3)
fvz.destroy()
if os.path.exists("D:\\fvz_study") == False and os.path.exists("C:\\fvz_study") == False:
global dir_path
dir_path=StringVar()
dir_path.set("D盘")
optionmenu1=OptionMenu(root,dir_path,"C盘","D盘").place(relx=0.44,rely=0.6)
button1=Button(root,text="继续>",command=path).pack(side=BOTTOM)
label1=Label(root,text="选择盘符(因为某人的电脑没D盘,才有这个选项)",fg="grey").place(relx=0.25,rely=0.5)
else:
path_ok=True
while True:
if path_ok==True:
th3=threading.Thread(target=ok,args=())
th3.setDaemon(True)
th3.start()
break
class Form:
def __init__(self,form):
form.attributes("-alpha", 0.95)
form.title("FVZ_文本编辑器")
form.geometry("500x300+200+200")
#form.overrideredirect(1)
global fvz
fvz=Label(form,text="FVZ",justify=CENTER,bg="RoyalBlue",fg="white",font=("微软雅黑",30))
fvz.place(relwidth=1,relheight=1,relx=0,rely=0)
root = Tk()
app=Form(root)
#多线程
th=threading.Thread(target=FVZ_win,args=())#创建线程(target=函数名,args=(参数[,]))
th.setDaemon(True)#守护线程
th.start()#开始线程
mainloop()
大神求解
展开