Reputation: 222
I am trying to make a simple explorer with tkinter python and I want to add a right click option to the files and folder buttons like copy, cut, delete, etc.
If somehow I can add a frame to wherever the user has right clicked then I can place all the buttons in that frame.
This is the file.
Please help and Thanks in advance.
Upvotes: 0
Views: 285
Reputation: 136
Here is an example Tkinter file that has the features you're talking about:
import tkinter
from tkinter import *
root = Tk()
L = Label(root, text ="Right-click to display menu",
width = 40, height = 20)
L.pack()
m = Menu(root, tearoff = 0)
m.add_command(label ="Cut")
m.add_command(label ="Copy")
m.add_command(label ="Paste")
m.add_command(label ="Reload")
m.add_separator()
m.add_command(label ="Rename")
def do_popup(event):
try:
m.tk_popup(event.x_root, event.y_root)
finally:
m.grab_release()
L.bind("<Button-3>", do_popup)
mainloop()
Implement it as you need
Upvotes: 2