Редактор работает отлично, но есть очень маленькая проблема: когда я выбираю 'Bold', стиль шрифта 'itali c' автоматически не выбирается, а когда я "UNDERLINE", текст выделяется жирным шрифтом и itali c не выбраны, Короче говоря, одна функция работает только каждый раз. Я перепробовал все возможные способы, которые комментируются с кодом
#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)
Это изображение выглядит как мой текстовый редактор
![image](https://i.stack.imgur.com/l7Zkp.png)
Подчеркивание
![image](https://i.stack.imgur.com/Cyo0L.png)
Жирный
![image](https://i.stack.imgur.com/Ggssc.png)
Италия c
![image](https://i.stack.imgur.com/9BQlT.png)