The editor works perfectly but there is very small problem is that when I select 'Bold' font-style 'italic' is automatically un-selected and when I "UNDERLINE" text bold and italic are un-selected, In short, one function is working only at each time. I tried all possible ways those are commented with code
#BOLD BUTTON FUNCTIONALITY
def change_bold():
text_property = tk.font.Font(font = text_editor['font'])
if text_property.actual()['weight'] == 'normal':
text_editor.configure(font= (current_font_family, current_font_size, 'bold'))
if text_property.actual()['weight'] == 'bold':
text_editor.configure(font= (current_font_family, current_font_size, 'normal'))
if text_property.actual()['slant'] == 'italic':
text_editor.configure(font= (current_font_family, current_font_size, 'bold','italic'))
bold_button.configure(command = change_bold)
# ITALIC BUTTON FUNCTIONALITY
def change_italic():
text_property = tk.font.Font(font = text_editor['font'])
if text_property.actual()['slant'] == 'roman':
text_editor.configure(font= (current_font_family, current_font_size, 'italic'))
if text_property.actual()['slant'] == 'italic':
text_editor.configure(font= (current_font_family, current_font_size, 'normal'))
if text_property.actual()['weight'] == 'bold':
text_editor.configure(font= (current_font_family, current_font_size, 'bold','italic'))
italic_button.configure(command = change_italic)
# UNDERLINE BUTTON FUNCTIONALITY
def change_underline():
text_property = tk.font.Font(font = text_editor['font'])
if text_property.actual()['underline'] == 0:
text_editor.configure(font= (current_font_family, current_font_size, 'underline'))
if text_property.actual()['underline'] == 1:
text_editor.configure(font= (current_font_family, current_font_size, 'normal'))
# if text_property.actual()['weight'] == 'normal' and text_property.actual()['slant'] == 'roman':
# text_editor.configure(font= (current_font_family, current_font_size, 'normal','roman',1))
# if text_property.actual()['weight'] == 'bold' and text_property.actual()['slant'] == 'roman':
# text_editor.configure(font= (current_font_family, current_font_size, 'bold','roman',1))
# if text_property.actual()['weight'] == 'bold' and text_property.actual()['slant'] == 'italic':
# text_editor.configure(font= (current_font_family, current_font_size, 'bold','italic',1))
# if text_property.actual()['weight'] == 'normal' and text_property.actual()['slant'] == 'italic':
# text_editor.configure(font= (current_font_family, current_font_size, 'normal','italic',1))
underline_button.configure(command = change_underline)
This image is a look of my text editor
Underline
Bold
Italic



