tkinter 实现右键复制


from tkinter import *
def cut(event=None):
    listbox.event_generate("<<Cut>>")
def copy(event=None):
    listbox.event_generate("<<Copy>>")
def paste(event=None):
    texteditor.event_generate('<<Paste>>')
root=Tk()
texteditor=Text(root)
texteditor.pack(fill=BOTH)
menubar=Menu(root)
filemenu=Menu(menubar)
root.config(menu=menubar)
filemenu.add_command(label="Cut",command=cut)
filemenu.add_command(label="Copy",command=copy)
filemenu.add_command(label="Paste",command=paste)
menubar.add_cascade(label="File",menu=filemenu)
root.mainloop()

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM