Reputation: 11
I have Label and event Enter on Label and when event fired I want get whether the cursor is holding a file if cursor holding a file get path of this file
Upvotes: -1
Views: 76
Reputation: 48
Is this what you are looking for?
import tkinter as tk
from tkinter import filedialog
def on_label_click(event):
# Check if a file is selected
file_path = tk.filedialog.askopenfilename()
if file_path:
label.config(text="Selected File: " + file_path)
# Create the main application window
root = tk.Tk()
root.title("File Cursor Check")
# Create the label widget
label = tk.Label(root, text="Enter")
label.pack()
# Bind the event to the label widget
label.bind("<Button-1>", on_label_click)
root.mainloop()
Upvotes: 0