Computer >> कंप्यूटर ट्यूटोरियल >  >> प्रोग्रामिंग >> Python

Tkinter में Mouse Cursor Change कैसे करें?

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 बनेंगे।

Tkinter में Mouse Cursor Change कैसे करें?

  1. पायथन Tkinter में बटन का साइज़ कैसे बदलें? पायथन Tkinter में बटन का साइज़ कैसे बदलें?

    Tkinter Button विजेट्स एप्लिकेशन के लिए आवश्यक बटन बनाने के लिए उपयोग किए जाते हैं। हम बटन कंस्ट्रक्टर में एक इवेंट ऑब्जेक्ट भी जोड़ सकते हैं और कुछ ऑपरेशन करने के लिए इसे ट्रिगर कर सकते हैं। बटन साइज़ को कस्टमाइज़ करने के लिए, हम बटन विजेट के width और height प्रॉपर्टी का उपयोग कर सकते हैं। उदाहरण

  1. Tkinter में फ्रेम का बैकग्राउंड कैसे बदलें? Tkinter में फ्रेम का बैकग्राउंड कैसे बदलें?

    Tkinter फ्रेम का बैकग्राउंड कलर और फोरग्राउंड कलर बदलने के लिए, हम Frame फंक्शन में bg और fg पैरामीटर्स को अलग-अलग वैल्यूज़ असाइन कर सकते हैं। उदाहरण इस उदाहरण में, हमने अलग-अलग बैकग्राउंड कलर्स के साथ दो फ्रेम्स बनाए हैं। # आवश्यक लाइब्रेरीज़ इम्पोर्ट करें from tkinter import * # tkinter फ्रेम का

  1. Tkinter में Button में Bitmap Images का उपयोग कैसे करें? Tkinter में Button में Bitmap Images का उपयोग कैसे करें?

    Tkinter में, हम images का उपयोग करके buttons बना और customize कर सकते हैं। इन images को Python PhotoImage(file) फंक्शन का उपयोग करके upload किया जा सकता है। हालांकि, PhotoImage() केवल कुछ image types जैसे PNG, PPM, और GIF support करता है। इसके अलावा, हम BitMap images का उपयोग करके भी buttons बना सकत