-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathText editor notebook.py
37 lines (26 loc) · 1.03 KB
/
Text editor notebook.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from tkinter import *
import tkinter as tk
from tkinter.filedialog import asksaveasfilename
stimulator_window = Tk()
stimulator_window.geometry('600x600')
stimulator_window.title('TEXT EDITOR')
heading = Label(stimulator_window,text='Welcome to the Text Editor',font=('bold',20),bg='light grey') # This will creat a label for the heading.
heading.pack()
scrollbar = Scrollbar(stimulator_window)
scrollbar.pack(side=RIGHT,
fill=Y)
text_info = Text(stimulator_window,
yscrollcommand=scrollbar.set)
text_info.pack(fill=BOTH)
scrollbar.config(command=text_info.yview)
def save():
filepath = asksaveasfilename(defaultextension="txt",filetypes=[("Text Files", "*.txt"), ("All Files", "*.*")])
if not filepath:
return
with open(filepath, "w") as output_file:
text = Editor.get(1.0, tk.END)
output_file.write(text)
stimulator_window.title(f"Entitled - {filepath}")
button = Button(stimulator_window,text='Save',font=('normal',10),command=save, bg='yellow')
button.place(x=270,y=520)
stimulator_window.mainloop()