我一直在尝试更改Tkinter中的光标。这是我的代码:
# explore_Tkinter.py
from Tkinter import *
def callback1(event):
print "one clicked at", event.x, event.y
def callback2(event):
print "two clicked at", event.x, event.y
root = Tk()
img = PhotoImage(file = "image002.gif")
canvas = Canvas(root, width = 1000, height = 700, cursor = "crosshair")
s1 = canvas.cget('cursor')
print "s1 ", s1
canvas.pack()
canvas.create_image(100, 200, image = img, anchor = 'nw')
canvas.bind("<Button-1>", callback1)
canvas.bind("<Button-2>", callback2)
mainloop()
当我运行时,程序打印
s1 crosshair
表示光标已被更改,但图像上的实际光标保持不变(“箭头”)。
做错了什么或做错了什么?
答案 0 :(得分:-2)
我喜欢在我的画布上使用一个普通的光标,就像这样
import tkinter
tk = tkinter.Tk()
canvas = tkinter.Canvas(tk, cursor="diamond_cross", width=800, height=600, bg="white")
并且您可以从here找到更多游标。