0
我正在使用Python 2.7.6你可以更新tkinter中單選按鈕的文本和值嗎?
我剛剛開始使用Tkinter,最近我正在將一個命令提示符測驗轉換成一個GUI測驗。到目前爲止,除了我使用的單選按鈕外,我已經取得了成功。我可以創建一組單選按鈕並在需要時提取它們的值,但我不確定在單擊「下一步」按鈕後如何更新單選按鈕的文本和值。
這不是我的整個代碼,因爲它超過800行,但這裏是我創建單選按鈕和功能def Guide():
的淡化版本,我想更新單選按鈕。
假設Guide_list[Current].R1
和Guide_list[Current].V1
分別檢索正確的字符串和整數。
「當前」是我的櫃檯。
from Tkinter import *
app=Tk()
Current=0
R=IntVar()
R.set(None)
Resp1=Radiobutton(app, text=Guide_list[Current].R1, value=Guide_list[Current].V1,variable=R).pack(anchor=W)
Resp2=Radiobutton(app, text=Guide_list[Current].R2, value=Guide_list[Current].V2,variable=R).pack(anchor=W)
Resp3=Radiobutton(app, text=Guide_list[Current].R3, value=Guide_list[Current].V3,variable=R).pack(anchor=W)
Resp4=Radiobutton(app, text=Guide_list[Current].R4, value=Guide_list[Current].V4,variable=R).pack(anchor=W)
Resp5=Radiobutton(app, text=Guide_list[Current].R5, value=Guide_list[Current].V5,variable=R).pack(anchor=W)
Resp6=Radiobutton(app, text="N/A", value="N/A",variable=R).pack(anchor=W)
def Guide():
global Current
Current=Current+1
### Insert code to update the radio buttons ###
button2=Button(app,text="Next", width=15,command=Guide)
button2.pack(side='bottom')
app.mainloop()
嘿,我可以問你是否使用任何教程學習Tkinter?我看到很多人使用相同的「任務+包裝反模式」,我試圖追蹤他們從哪裏得到它。 – Kevin 2014-09-20 15:17:40
我正在使用我在Youtube上找到的各種教程。 – 2014-09-23 14:58:41