[問題] 製作備忘錄出現的小問題已刪文

看板Python作者 (狗狗睪丸被割)時間5年前 (2019/10/04 09:26), 5年前編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
我原本想說 設兩個按鈕選項 急件 普通件 點了以後 再輸入文字 如果是急件 就多加一個星號 但目前沒反應 看來是沒抓到choice這個變數 請問何解? 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 if choice == "普通件": wwe=url.get() f=open("D:\\Desktop\\python測試\\111\\代辦清單.txt","a+") f.write('\n'+wwe) f.close elif choice =="急件": wwe=url.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="急件", command=add) rb2.place(x=10, y=20) rb3 = tk.Radiobutton(win, text='普通件', variable=choice, value="普通件", command=add) rb3.place(x=10, y=45) win.mainloop() -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 117.56.227.246 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1570152373.A.08A.html ※ 編輯: gogogo123 (117.56.227.246 臺灣), 10/04/2019 09:42:30
文章代碼(AID): #1Tbf-r2A (Python)
文章代碼(AID): #1Tbf-r2A (Python)