File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
WINDOW_WIDTH: int = 90
1313
WINDOW_HEIGHT: int = 25
1414
FILE_NAME: str = None
15-
font_dict = {}
1615
DEFAULT_FONT_NAME: str = 'Times New Roman'
1716

1817
def ShowFontDialog():
@@ -34,37 +33,45 @@ def ShowFontDialog():
3433
data = dialog.GetFontData()
3534
font = data.GetChosenFont()
3635

36+
# extract the seletec settings in the dialog
37+
# to construct the font style modifiers.
3738
font_info = font.GetNativeFontInfoUserDesc()
3839
selected_styles = shlex.split(font_info)
3940

41+
# font bold.
4042
if 'bold' in selected_styles:
4143
font_style_modifier += 'bold '
4244

45+
# font italic.
4346
if 'italic' in selected_styles:
4447
font_style_modifier += 'italic '
4548

49+
# font underline.
4650
if font.GetUnderlined():
4751
font_style_modifier += 'underline '
4852

53+
# font strikethrough/overstrike.
4954
if font.GetStrikethrough():
5055
font_style_modifier += 'overstrike '
5156

57+
# get the selected font/text color.
5258
font_color = data.GetColour()
5359
font_color = rgb2hex(font_color[0], font_color[1], font_color[2])
5460

61+
# get the selected font name and size.
5562
font_facename = font.GetFaceName()
56-
5763
font_size = font.GetPointSize()
5864

59-
WINDOW['-BODY-'].update(font=(font_facename, font_size, font_style_modifier),
65+
# update the font as per the above settings.
66+
WINDOW['-BODY-'].update(font=(font_facename, font_size, font_style_modifier.rstrip()),
6067
text_color=font_color)
6168

6269

6370
def rgb2hex(r, g, b):
6471
'''Convert RGB to hex values.'''
6572
return "#{:02x}{:02x}{:02x}".format(r, g, b)
6673

67-
# string variables to shorten loop and menu code
74+
# file menu constants.
6875
file_new: str = 'New (CTRL+N)'
6976
file_open: str = 'Open (CTRL+O)'
7077
file_save: str = 'Save (CTRL+S)'
@@ -214,6 +221,7 @@ def about():
214221
if EVENT in (sg.WINDOW_CLOSED, 'Exit'):
215222
# exit out of the application is close or exit clicked.
216223
break
224+
217225
if EVENT in (file_new, 'n:78'):
218226
new_file()
219227
if EVENT in (file_open, 'o:79'):

0 commit comments

Comments
 (0)