Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- root = Tk()
- def fopen():
- try:
- file_name = entry.get()
- file = open(file_name)
- text.delete(1.0, END)
- text.insert(1.0, file.read())
- file.close()
- except:
- pass
- def fsave():
- try:
- file_name = entry.get()
- file = open(file_name, 'w')
- texting = text.get(1.0, END)
- file.write(texting)
- file.close()
- except:
- pass
- f1 = Frame()
- f2 = Frame()
- f3 = Frame()
- f1.pack()
- f2.pack(padx=3, pady=2)
- f3.pack()
- entry = Entry(f1, width=50)
- entry.pack(side=LEFT)
- _open = Button(f1, width=10, text='open', command=fopen)
- _open.pack(side=LEFT, padx=3)
- save = Button(f1, width=10, text='save', command=fsave)
- save.pack(side=LEFT, padx=3)
- text = Text(f2, height=50, width=100)
- text.pack()
- # -------scrollbar--------
- scrollY = Scrollbar(f2, command=text.yview)
- scrollY.pack(side=LEFT, fill=Y)
- text.config(yscrollcommand=scrollY.set)
- scrollX = Scrollbar(f3, command=text.xview)
- scrollX.pack(side=BOTTOM, fill=X)
- text.config(xscrollcommand=scrollX.set)
- root.title('Text editor')
- root.mainloop()
Add Comment
Please, Sign In to add comment