亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

是否可以為 Checkbutton 小部件(tkinter)設置 2 個不同的光標?

是否可以為 Checkbutton 小部件(tkinter)設置 2 個不同的光標?

UYOU 2023-03-01 15:40:53
我在網上搜索過但沒有回應。我使用了一個帶有 indicatoron=FALSE 的 tkinter Checkbutton,這讓它看起來只是一個按鈕。我已經設置了一個光標,但我想知道是否可以為復選按鈕的開/關狀態設置 2 個不同的光標。例如:test = tk.Checkbutton(self.frame, text=self.name, indicatoron=False, selectcolor="green", background="red", variable=self.varbutton, command=self.launchsound, cursor="plus")  test.pack()
查看完整描述

1 回答

?
紅顏莎娜

TA貢獻1842條經驗 獲得超13個贊

你可以讓它取決于varbutton你的變量command:


import tkinter as tk


def changeCursor():

    if varbutton.get():

        test['cursor'] = 'hand2'

    else:

        test['cursor'] = 'plus'

    # pass


r = tk.Tk()

varbutton = tk.BooleanVar()

test = tk.Checkbutton(r, text="a", indicatoron=False, selectcolor="green", background="red", cursor="plus", command=changeCursor, variable=varbutton)

test.pack()

r.mainloop()


查看完整回答
反對 回復 2023-03-01
  • 1 回答
  • 0 關注
  • 128 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號