Tkinter एक GUI-based Python library है जिसका उपयोग विभिन्न प्रकार के functional और GUI-based applications develop करने के लिए किया जाता है। यह एप्लिकेशन develop करते समय extensibility और विभिन्न features प्रदान करने के लिए बहुत सारे functions और methods प्रदान करता है।
इस लेख में, हम देखेंगे कि tkinter frame में button पर hover करते समय mouse cursor को cursor property का उपयोग करके कैसे change करें। Tkinter के button library में बहुत सारे cursor maps उपलब्ध हैं जो end-user के लिए अलग-अलग visuals प्रदान करते हैं। कुछ cursor library में हैं:
"arrow", "circle", "clock", "cross", "dotbox", "exchange", "fleur", "heart", "man", "mouse", "pirate", "plus", "shuttle", "sizing", "spider", "spraycan", "star", "target", "tcross", "trek", "watch"
आइए पहले कुछ buttons बनाएं और फिर हम इनमें से कुछ cursors को mouse pointer पर apply करेंगे।
उदाहरण
from tkinter import *
# Create an instance of window or frame
win = Tk()
# Set the geometry
win.geometry("700x600")
win.resizable(0, 0)
win.config(cursor="fleur")
# Let us create a text label
Label(win, text="Hover on each of these buttons", font=('Poppins', 20)).pack(pady=20)
# Create some buttons with cursor property
b1 = Button(win, text="Star", cursor="star")
b1.pack(pady=20)
b2 = Button(win, text="Arrow", cursor="arrow")
b2.pack(pady=20)
b3 = Button(win, text="Circle", cursor="circle")
b3.pack(pady=20)
b4 = Button(win, text="Clock", cursor="clock")
b4.pack(pady=20)
b5 = Button(win, text="Heart", cursor="heart")
b5.pack(pady=20)
b6 = Button(win, text="Man", cursor="man")
b6.pack(pady=20)
b7 = Button(win, text="Mouse", cursor="mouse")
b7.pack(pady=20)
# Keep Running the window
win.mainloop()
आउटपुट
उपरोक्त code चलाने से different mouse pointer shapes के साथ different buttons बनेंगे।
