
source
I've already made a text editor software. I used tkinter module of python for building the software. I want to share the codes of the software with the hiveans.
Tkinter is a module of python. It can be used to create GUI based applications. GUI stands for Graphical User Interface. You can use tkinter for building GUI based applications.
I am a newbie on python. After learning all the basics of python, I have started to learn tkinter. While learning tkinter, I built this software. I hope you guys will like it.
Let's jump to the code.
Toolbar
# ************************ Toolbar ***********************
tool_bar = tk.Label(main_application)
tool_bar.pack(side=tk.TOP, fill=tk.X)
# font box
font_tuple = tk.font.families()
font_family = tk.StringVar()
font_box = ttk.Combobox(tool_bar, width=30, state='readonly', textvariable=font_family)
font_box['values'] = font_tuple
font_box.grid(row=0, column=0, padx=5)
font_box.current(font_tuple.index('Arial'))
# size box
size_var = tk.IntVar()
font_size = ttk.Combobox(tool_bar, width=14, state='readonly', textvariable=size_var)
font_size['values'] = tuple(range(6, 81, 2))
font_size.current(3)
font_size.grid(row=0, column=1, padx=5)
# bold btn
bold_icon = tk.PhotoImage(file='TextEditorIcons/bold.png')
bold_btn = tk.Button(tool_bar, image=bold_icon)
bold_btn.grid(row=0, column=2, padx=5)
# italic btn
italic_icon = tk.PhotoImage(file='TextEditorIcons/italic.png')
italic_btn = tk.Button(tool_bar, image=italic_icon)
italic_btn.grid(row=0, column=3, padx=5)
# underline btn
underline_icon = tk.PhotoImage(file='TextEditorIcons/underline.png')
underline_btn = tk.Button(tool_bar, image=underline_icon)
underline_btn.grid(row=0, column=4, padx=5)
# font color btn
font_color_icon = tk.PhotoImage(file='TextEditorIcons/font_color.png')
font_color_btn = tk.Button(tool_bar, image=font_color_icon)
font_color_btn.grid(row=0, column=5, padx=5)
# align left btn
align_left_icon = tk.PhotoImage(file='TextEditorIcons/align_left.png')
align_left_btn = tk.Button(tool_bar, image=align_left_icon)
align_left_btn.grid(row=0, column=6, padx=5)
# align center btn
align_center_icon = tk.PhotoImage(file='TextEditorIcons/align_center.png')
align_center_btn = tk.Button(tool_bar, image=align_center_icon)
align_center_btn.grid(row=0, column=7, padx=5)
# align right btn
align_right_icon = tk.PhotoImage(file='TextEditorIcons/align_right.png')
align_right_btn = tk.Button(tool_bar, image=align_right_icon)
align_right_btn.grid(row=0, column=8, padx=5)
# ----------------------- End Tool Bar --------------------