We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import os; from tkinter import *; from tkinter import filedialog, colorchooser, font; from tkinter.messagebox import showinfo def change_color(): color = colorchooser.askcolor(title="Choose color") text_area.config(fg=color[1]) def change_font(*args): text_area.config(font=(font_name.get(), str(font_size.get()))) def new_file(): window.title("Untitled"), text_area.delete(1.0, END) def open_file(): file = filedialog.askopenfilename(defaultextension=".txt", filetypes=[("All Files", "*.*"), ("Text Documents", "*.txt")]) if file: window.title(os.path.basename(file)) text_area.delete(1.0, END) with open(file, "r") as f: text_area.insert(1.0, f.read()) def save_file(): file = filedialog.asksaveasfilename(initialfile='untitled.txt', defaultextension=".txt", filetypes=[("All Files", "*.*"), ("Text Documents", "*.txt")]) if file: with open(file, "w") as f: f.write(text_area.get(1.0, END)) window.title(os.path.basename(file)) def cut(): text_area.event_generate("<<Cut>>") def copy(): text_area.event_generate("<<Copy>>") def paste(): text_area.event_generate("<<Paste>>") def about(): showinfo("About", "Made this for fun") window = Tk() window.title("Happy Happy Halloween") window.geometry("1000x800") font_name, font_size = StringVar(value="Courier"), StringVar(value="28") text_area = Text(window, font=(font_name.get(), font_size.get()), wrap=WORD) text_area.grid(sticky=N+E+S+W, padx=5, pady=5) scroll_bar = Scrollbar(text_area) scroll_bar.pack(side=RIGHT, fill=Y) text_area.config(yscrollcommand=scroll_bar.set) window.grid_rowconfigure(0, weight=1) window.grid_columnconfigure(0, weight=1) frame = Frame(window) frame.grid() color_button = Button(frame, text="Color", command=change_color) color_button.grid(row=0, column=0) font_box = OptionMenu(frame, font_name, *font.families(), command=change_font) font_box.grid(row=0, column=1) size_box = Spinbox(frame, from_=1, to=100, textvariable=font_size, command=change_font) size_box.grid(row=0, column=2) menu_bar = Menu(window) window.config(menu=menu_bar) file_menu = Menu(menu_bar, tearoff=0) menu_bar.add_cascade(label="File", menu=file_menu), file_menu.add_command(label="New", command=new_file) file_menu.add_command(label="Open", command=open_file), file_menu.add_command(label="Save", command=save_file) file_menu.add_separator(), file_menu.add_command(label="Exit", command=window.destroy) edit_menu = Menu(menu_bar, tearoff=0) menu_bar.add_cascade(label="Edit", menu=edit_menu), edit_menu.add_command(label="Cut", command=cut) edit_menu.add_command(label="Copy", command=copy), edit_menu.add_command(label="Paste", command=paste) help_menu = Menu(menu_bar, tearoff=0) menu_bar.add_cascade(label="Help", menu=help_menu), help_menu.add_command(label="About", command=about) window.mainloop()
The text was updated successfully, but these errors were encountered:
As long as it works, its super cool
Sorry, something went wrong.
No branches or pull requests
The text was updated successfully, but these errors were encountered: