Python基于Tkinter实现的记事本实例

yipeiwu_com7年前Python基础

本文实例讲述了Python基于Tkinter实现的记事本。分享给大家供大家参考。具体如下:

from Tkinter import *
root = Tk('Simple Editor')
mi=StringVar()
Label(text='Please input something you like~' ).pack()
te = Text(height = 30,width =100)
te.pack()
Label(text='      File name     ').pack(side = LEFT)
Entry(textvariable = mi).pack(side = LEFT)
mi.set('*.txt')
def save():
  t = te.get('0.0','10.0')
  f = open(mi.get(),'w')
  f.write(t)
Button(text = 'Save' , command = save).pack(side = RIGHT)
Button(text = 'Exit' , command = root.quit).pack(side = RIGHT)
mainloop()

希望本文所述对大家的Python程序设计有所帮助。

相关文章

Python使用matplotlib实现在坐标系中画一个矩形的方法

Python使用matplotlib实现在坐标系中画一个矩形的方法

本文实例讲述了Python使用matplotlib实现在坐标系中画一个矩形的方法。分享给大家供大家参考。具体实现方法如下: import matplotlib.pyplot as p...

pytorch 输出中间层特征的实例

pytorch 输出中间层特征: tensorflow输出中间特征,2种方式: 1. 保存全部模型(包括结构)时,需要之前先add_to_collection 或者 用slim模块下的e...

使用Python写CUDA程序的方法

使用Python写CUDA程序有两种方式: * Numba * PyCUDA numbapro现在已经不推荐使用了,功能被拆分并分别被集成到accelerate和Numba了。 例子...

python实现统计代码行数的方法

本文实例讲述了python实现统计代码行数的方法。分享给大家供大家参考。具体实现方法如下: ''' Author: liupengfei Function: count lines...

python开发之thread实现布朗运动的方法

python开发之thread实现布朗运动的方法

本文实例讲述了python开发之thread实现布朗运动的方法。分享给大家供大家参考,具体如下: 这里我将给大家介绍有关python中thread来实现布朗运动的一个例子 下面是运行效果...