作者gogogo123 (狗狗睾丸被割)
看板Python
标题[问题] 怎麽让tk.INSERT前面加上(1 (2 (3跟改颜色
时间Fri Oct 4 11:25:02 2019
\以下是我程式码
输入完代办事项後 选急件或普通件 急件会加上星号
但目前想让显示出来的win1 视窗 有项目数字
如果是print 还好办 直接
for index,line in f(start=1):
print({}){}.format(index,line))
但我用的是tk.INSERT 开新程式视窗 该怎麽自动跑项目呢?
顺便一问 如果我想急件出现的是红色字该怎麽加入 试过fg但不行
import tkinter as tk
def check():
f=open('D:\\Desktop\\python测试\\111\\代办清单.txt','r')
f.close
win1=tk.Tk()
text=tk.Text(win1,font=("标楷体",16))
for line in f:
text.insert(tk.INSERT,line)
text.pack()
def add():
global url,choice
choices=choice.get()
if choices == "普通件":
wwe=url.get()
f=open("D:\\Desktop\\python测试\\111\\代办清单.txt","a+")
f.write('\n'+" "+wwe)
f.close
else:
wwe=url.get()
choice.get()
f=open("D:\\Desktop\\python测试\\111\\代办清单.txt","a+")
f.write('\n'+"★"+wwe)
f.close
win=tk.Tk()
win.geometry("450x380") #设定主视窗解析度
win.title("备忘录")
choice = tk.StringVar() #选项按钮值
url = tk.StringVar() #代办内容
label1=tk.Label(win, text="输入代办事项:")
label1.place(x=10, y=80)
entryUrl = tk.Entry(win, textvariable=url)
entryUrl.config(width=45)
entryUrl.place(x=100, y=80)
button=tk.Button(win,text="送出",command=add)
button.place(x=200, y=110)
button=tk.Button(win,text="查看代办清单",command=check)
button.place(x=300, y=110)
rb2 = tk.Radiobutton(win, text='急件', variable=choice, value="急件")
rb2.place(x=10, y=20)
rb3 = tk.Radiobutton(win, text='普通件', variable=choice, value="普通件")
rb3.place(x=10, y=45)
win.mainloop()
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 117.56.227.246 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1570159505.A.B93.html
※ 编辑: gogogo123 (117.56.227.246 台湾), 10/04/2019 11:25:37
3F:→ chliu6: 为字串上颜色脱离不了index() tag_add() tag_config() 10/05 21:29