有段時間刪了電腦裏的亂七八糟的軟件,各種IDE也沒了,學python的時候感覺用記事本敲代碼還挺爽,就是敲完得改後綴,有點麻煩,遂用了IDLE。現在準備學web,有時候敲敲html,不想下IDE,都是寫完txt改html,然後用Chrome打開,現在自己用python寫了一個自動完成這個過程的:
from tkinter import *
import os
def func(text):
with open('text.html','wb') as f:
f.write(text.encode('utf-8'))
os.popen('chrome text.html')
root = Tk()
root.title('myIDE')
text = Text(root)
text.pack(fill='both',expand=YES)
Button(root,text='run',command=lambda:func(text.get(0.0,END))).pack(side='right')
root.mainloop()
效果:
把給Chrome設一下環境變量,就可以用了。編寫好之後點擊run按鈕,html就會在Chrome中打開
——一個自娛自樂的沙雕