Python之tkinter:動(dòng)態(tài)演示調(diào)用python庫(kù)的tkinter帶你進(jìn)入GUI世界(LabelFrame/Checkbutton/Radiobutton)
導(dǎo)讀
動(dòng)態(tài)演示調(diào)用python庫(kù)的tkinter帶你進(jìn)入GUI世界(LabelFrame/Checkbutton/Radiobutton)
tkinter應(yīng)用案例—LabelFrame/Checkbutton/Radiobutton
1、tkinter:tkinter應(yīng)用案例之便簽框架LabelFrame的應(yīng)用將組件(多選按鈕)放到一個(gè)框架里
import tkinter
root=Tk()
root.title("Jason niu工作室")
group=LabelFrame(root,text="關(guān)于區(qū)塊鏈技術(shù),你想了解的是哪方面的知識(shí)?",padx=5,pady=5)
group.pack(padx=15,pady=15)
LANGS=[("共識(shí)機(jī)制",1),("P2P網(wǎng)絡(luò)",2),("加密算法",3),("數(shù)據(jù)存儲(chǔ)",4),("智能合約",5),("跨鏈技術(shù)",6)]
v=IntVar()
for lang,num in LANGS:
b=Radiobutton(group,text=lang,variable=v,value=num)
b.pack(anchor=W)
mainloop()
2、tkinter應(yīng)用案例之多選按鈕Checkbutton的應(yīng)用
# tkinter:tkinter應(yīng)用案例之多選按鈕Checkbutton的應(yīng)用
import tkinter
root=Tk()
root.title("Jason niu工作室")
lists=['AI','ML','DL','RL']
v=[]
for each in lists:
v.append(IntVar())
b=Checkbutton(root,text=each,variable=v[-1])
b.pack(anchor=W)
mainloop()
3、tkinter應(yīng)用案例之單選按鈕Radiobutton的應(yīng)用
#tkinter:tkinter應(yīng)用案例之單選按鈕Radiobutton的應(yīng)用
root=Tk()
root.title("Jason niu工作室")
LANGS=[("python",1),("java",2),("matlab",3),("vrml",4),("C語(yǔ)言",5),("C++",4)]
v=IntVar()
v.set(1)
for lang,num in LANGS:
b=Radiobutton(root,text=lang,variable=v,value=num,indicatoron=False)
b.pack(fill=X)
# b=Radiobutton(root,text=lang,variable=v,value=num)
# b.pack(anchor=W)
mainloop()