我已经冒昧地缩短代码以适应我的问题我一直试图弄清楚如何在我用Python编写的文本编辑器中实现撤消,重做,复制和剪切按钮。我在互联网上看过一些例子,但我遇到了实施问题。任何帮助将不胜感激!
from tkinter import *
import os
import tkinter
import tkinter.scrolledtext as ScrolledText
from tkinter import Tk, scrolledtext, Menu, filedialog, messagebox, Text, simpledialog, filedialog
import requests
import urllib.request
#Functions
def donothing():
messagebox.showinfo('Not Implimented', 'This option has not been implimented yet!')
root = Tk()
menu = Menu(root)
root.config(menu=menu)
root.title('Written in Python')
root.minsize(width=100, height=100)
root.geometry('800x500+350+150') #Height, Width, X, Y coordinates of the program
#NotePad
textArea = ScrolledText.ScrolledText(root, width=100, height=100) #Height and width of notepad
textArea.pack()
editMenu = Menu(menu)
menu.add_cascade(label="Edit",menu=editMenu)
editMenu.add_command(label="Undo", command=donothing)
editMenu.add_command(label="Redo", command=donothing)
editMenu.add_command(label="Cut", command=donothing)
editMenu.add_command(label="Copy", command=donothing)
root.mainloop()
答案 0 :(得分:0)
所以我想出来了,这就是我所做的。
def delete():
notepad.delete(0.0, END)
def redo():
notepad.edit_redo()
def undo():
notepad.edit_undo()