12
12
WINDOW_WIDTH : int = 90
13
13
WINDOW_HEIGHT : int = 25
14
14
FILE_NAME : str = None
15
- font_dict = {}
16
15
DEFAULT_FONT_NAME : str = 'Times New Roman'
17
16
18
17
def ShowFontDialog ():
@@ -34,37 +33,45 @@ def ShowFontDialog():
34
33
data = dialog .GetFontData ()
35
34
font = data .GetChosenFont ()
36
35
36
+ # extract the seletec settings in the dialog
37
+ # to construct the font style modifiers.
37
38
font_info = font .GetNativeFontInfoUserDesc ()
38
39
selected_styles = shlex .split (font_info )
39
40
41
+ # font bold.
40
42
if 'bold' in selected_styles :
41
43
font_style_modifier += 'bold '
42
44
45
+ # font italic.
43
46
if 'italic' in selected_styles :
44
47
font_style_modifier += 'italic '
45
48
49
+ # font underline.
46
50
if font .GetUnderlined ():
47
51
font_style_modifier += 'underline '
48
52
53
+ # font strikethrough/overstrike.
49
54
if font .GetStrikethrough ():
50
55
font_style_modifier += 'overstrike '
51
56
57
+ # get the selected font/text color.
52
58
font_color = data .GetColour ()
53
59
font_color = rgb2hex (font_color [0 ], font_color [1 ], font_color [2 ])
54
60
61
+ # get the selected font name and size.
55
62
font_facename = font .GetFaceName ()
56
-
57
63
font_size = font .GetPointSize ()
58
64
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 ()),
60
67
text_color = font_color )
61
68
62
69
63
70
def rgb2hex (r , g , b ):
64
71
'''Convert RGB to hex values.'''
65
72
return "#{:02x}{:02x}{:02x}" .format (r , g , b )
66
73
67
- # string variables to shorten loop and menu code
74
+ # file menu constants.
68
75
file_new : str = 'New (CTRL+N)'
69
76
file_open : str = 'Open (CTRL+O)'
70
77
file_save : str = 'Save (CTRL+S)'
@@ -214,6 +221,7 @@ def about():
214
221
if EVENT in (sg .WINDOW_CLOSED , 'Exit' ):
215
222
# exit out of the application is close or exit clicked.
216
223
break
224
+
217
225
if EVENT in (file_new , 'n:78' ):
218
226
new_file ()
219
227
if EVENT in (file_open , 'o:79' ):
0 commit comments