python text控件 只读_python tkinter 的Text控件为什么tag_add和tag_config用不了?

源代码如下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()

大神求解

展开

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值