用python3写一个简单的文本编辑器吧,参考[Create a Simple Python Text Editor!By PumpkinSmasher](https://www.instructables.com/Create-a-Simple-Python-Text-Editor/),原文太久远,不适合py3,下面对py3进行了一丢更改 ##开发环境 Deepin 20 , python3 3.7.3 ## 效果预览 照片好大。。 Deepin更新后无法...
import tkinter as tk window = tk.Tk() window.title("Simple Text Editor") window.rowconfigure(0, minsize=800, weight=1) window.columnconfigure(1, minsize=800, weight=1) txt_edit = tk.Text(window) fr_buttons = tk.Frame(window) btn_open = tk.Button(fr_buttons, text="Open") btn_save...
top = Tk() top. title("Simple Editor") contents = ScrolledText() contents.pack(side=BOTTOM, expand=True, fill=BOTH) filename = Entry() filename.pack(side=LEFT, expand=True, fill=X) Button(text='Open', command=load).pack(side=LEFT) Button(text='Save', command=save).pack(side=LEF...
Solution 1: Basic Text Editor Using Tkinter This solution uses the tkinter library to create a simple GUI-based text editor. It provides basic functionalities such as opening, editing, saving text files, and creating new files. Code: import tkinter as tk # Import tkinter for GUI from tkinter ...
text = input_file.read() txt_edit.insert(tk.END, text) window.title(f"Simple Text Editor - {filepath}") 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 第5 - 7 行使用tkinter.filedialog 模块中的askopenfilename() 对话来打开文件对话...
()11top.title("Simple Editor")12contents =ScrolledText()13contents.pack(side=BOTTOM, expand=True, fill=BOTH)14filename =Entry()15filename.pack(side=LEFT, expand=True, fill=X)16Button(text='Open', command=load).pack(side=LEFT)17Button(text='Save', command=save).pack(side=LEFT)18...
class SimpleEditor(ScrolledText): # see PyEdit for more definit(self, parent=None, file=None): frm = Frame(parent) frm.pack(fill=X) Button(frm, text='Save', command=self.onSave).pack(side=LEFT) Button(frm, text='Cut', command=self.onCut).pack(side=LEFT) ...
top.title("Simple Editor") top.geometry('800x600') contents = ScrolledText() contents.pack(side=BOTTOM, expand=True, fill=BOTH) filename = Entry(top) filename.pack(side=LEFT) Button(text='Open', command=load).pack(side=LEFT)
text =open(file,'r').read() self.text.delete('1.0', END) self.text.insert('1.0', text) self.text.mark_set(INSERT,'1.0') self.text.focus()defgettext(self):returnself.text.get('1.0', END+'-1c')classSimpleEditor(ScrolledText):def__init__(self, parent=None, file=None): ...
self.text.focus() def gettext(self): return self.text.get('1.0', END+'-1c') class SimpleEditor(ScrolledText): def __init__(self, parent=None, file=None): frm = Frame(parent) frm.pack(fill=X) Button(frm, text='Save', command=self.onSave).pack(side=LEFT) ...