2017.8.7 用python实现简单文本编辑器
来源:互联网 发布:天谕捏脸数据 编辑:程序博客网 时间:2024/06/17 08:37
import tkinter as tkimport tkinter.scrolledtext as tstclass Application(tk.Frame): def __init__(self,master=None): tk.Frame.__init__(self,master) self.grid() self.createWidgets() def createWidgets(self): self.textEdit=tst.ScrolledText(self,width=80,height=20) self.textEdit.grid(row=0,column=0,rowspan=6) self.btnOpen=tk.Button(self,text='打开',command=self.funcOpen) self.btnOpen.grid(row=1,column=1) self.btnSave=tk.Button(self,text='保存',command=self.funcSave) self.btnSave.grid(row=2,column=1) self.btnColor=tk.Button(self,text='颜色',command=self.funcColor) self.btnColor.grid(row=3,column=1) self.btnQuit=tk.Button(self,text='退出',command=self.funcQuit) self.btnQuit.grid(row=4,column=1) def funcOpen(self): self.textEdit.delete(1.0,tk.END) fname=tk.filedialog.askopenfilename(filetypes=[('文本文件','.txt')]) with open(fname,'r') as f: str1=f.read() self.textEdit.insert(0.0,str1) def funcSave(self): str1=self.textEdit.get(1.0,tk.END) fname=tk.filedialog.asksaveasfilename(filetypes=[('文本文件','.txt')]) with open(fname,'w') as f: f.write(str1) def funcColor(self): t,c=tk.colorchooser.askcolor(title='askcolor') self.textEdit.config(bg=c) def funcQuit(self): root.destroy()root=tk.Tk()root.title('文本编辑器')app=Application(master=root)app.mainloop()
阅读全文
0 0
- 2017.8.7 用python实现简单文本编辑器
- python简单文本编辑器
- python实现的文本编辑器
- Python使用wxpython制作简单文本编辑器
- 由Java实现简单的文本编辑器
- 简单文本编辑器设计与实现
- Javascript实现简单的富文本编辑器
- python通过Tkinter库实现的一个简单的文本编辑器代码
- 用python实现简单的文本情感分析
- 简单得文本编辑器
- 简单的文本编辑器
- 简单文本编辑器
- 简单的文本编辑器
- 简单文本编辑器
- PYTHON实现简单写文本日志
- python图片文本识别的简单实现
- python图片文本识别的简单实现
- python 实现简单的文本聚类
- 48. Rotate Image
- 记一次ajax跨域访问后,session失效
- 奇异值分解的推理及意义
- 创建用户以及用户授权
- 树的可见区域的获取和滚动条监听
- 2017.8.7 用python实现简单文本编辑器
- zabbix Warning: Using a password on the command line interface can be insecure
- 盛大游戏2017校招前端工程师笔试试卷
- 封装
- 【翻译】在Ext JS 5+ 使用ViewControllers
- Mac OS X下完全卸载MySQL
- log4j配置文件简介&slf4j
- C++ 怎样让函数返回数组
- [leetcode]19. Remove Nth Node From End of List@Java解题报告