tkinter check button

先宣個一個參數的物件

varB = tk.BooleanVar()

set  初始值

varB.set(True)


給 check button 設定 var 參數
ckBtn = tk.Checkbutton(root, text="I am a check button",var=varB)
ckBtn.grid(row=0, column =  0)

想要得到參數

ckBtn.get()



if  ckBtn.get() is True:
    print "I am true"



也可以把參數換成String

varB = tk.StringVar()

給 check button 設定 var 參數
ckBtn = tk.Checkbutton(root, text="i am a check button", var=varB,
onvalue="yes", offvalue="no")



想要得到參數
 ckBtn.get()



if  ckBtn.get() == "yes":
        print "I am yes"

留言

  1. Betfair Casino - Get 100% Bonus up to £100 + 200 Spins!
    Betfair Casino 코인갤러리 is a great alternative to other 코인갤 online 토토사이트코드 casinos, however the 피나클 company has a lot to offer and 바카라시스템배팅법 the software is superb and safe.

    回覆刪除

張貼留言

這個網誌中的熱門文章

python 找圖自動點擊

Python pyserial 抓取系統內的 COM PORT

VBA EXCEL 工作表變化 馬上執行 的作法 Worksheet_Change