为了账号安全,请及时绑定邮箱和手机立即绑定

是否可以为 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 关注
  • 146 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号