|
9 | 9 | import os |
10 | 10 | import pyfiglet |
11 | 11 |
|
12 | | -version = '6.0.1' |
| 12 | +version = '6.1' |
13 | 13 | __version__ = version.split()[0] |
14 | 14 |
|
15 | 15 | """ |
|
19 | 19 | 6.0 9-Apr-2026 Moved to LGPL3 license |
20 | 20 | Added "favorites" feature |
21 | 21 | 6.0.1 10-Apr-2026 Made Font list expand/contract with window. Sort favorites. |
| 22 | +6.0.2 15-Jun-2026 Added filtering of the font list to make finding fonts much easier. |
| 23 | +6.1 17-Jun-2026 Preparing for PyPI release |
22 | 24 | """ |
23 | 25 |
|
24 | 26 |
|
@@ -127,17 +129,17 @@ def make_window(): |
127 | 129 | favorite_fonts = [' '] |
128 | 130 | sg.theme_background_color(sg.theme_input_background_color()) |
129 | 131 | sg.theme_text_element_background_color(sg.theme_input_background_color()) |
130 | | - column_left = [[sg.Table(headings=['Font Name'], values=fonts, key='-FONT-LIST-', |
131 | | - col_widths=[40], num_rows=30, enable_events=True, expand_y=True), sg.VerticalSeparator(pad=((5, 5), 0))]] |
132 | | - try: |
133 | | - mline_input = sg.Multiline('PySimpleGUI', size=(40, 3), key='-TEXT-TO-SHOW-', no_scrollbar=True, enable_events=True, focus=True) |
134 | | - except Exception as e: |
135 | | - mline_input = sg.Multiline('PySimpleGUI', size=(40, 3), key='-TEXT-TO-SHOW-', enable_events=True, focus=True) |
| 132 | + # column_left = [[sg.Table(headings=['Font Name'], values=fonts, key='-FONT-LIST-', |
| 133 | + # col_widths=[40], num_rows=30, enable_events=True, expand_y=True), sg.VerticalSeparator(pad=((5, 5), 0))], |
| 134 | + # [sg.Input(s=20, k='-FILTER-')],[ sg.T('Filter')]] |
| 135 | + column_left = [[sg.Listbox(values=fonts, key='-FONT-LIST-',s=(30,30), justification='r', enable_events=True, expand_y=True, expand_x=True), sg.VerticalSeparator(pad=((5, 5), 0))], |
| 136 | + [sg.Input(s=20, k='-FILTER-', enable_events=True)],[ sg.T('Filter', justification='c', k='-FILTER-')]] |
| 137 | + mline_input = sg.Multiline('PySimpleGUI', size=(40, 3), key='-TEXT-TO-SHOW-', enable_events=True, focus=True) |
136 | 138 |
|
137 | 139 | column_right = [[sg.Combo(favorite_fonts, default_value=favorite_fonts[0], readonly=True, enable_events=True, k='-FAVORITES-', size=(max([len(f) for f in favorite_fonts]),30)), sg.Text("Font Name:", size=(10, 1)), sg.Input(selected_font, size=(12, 1), key='-FONT-NAME-'), sg.B('Add to favorites', k='-ADD TO FAVORITES-'), sg.B('Clear favorites', k='-CLEAR FAVORITES-')], |
138 | 140 | [sg.Text("Text:", size=(10, 1)), mline_input, sg.T('Font size for display below'), |
139 | 141 | sg.Combo(list(range(4, 20)), 12, enable_events=True, k='-FONT-SIZE-')], |
140 | | - [sg.Multiline(size=(LINE_LENGTH, 20), key='-OUTPUT-', border_width=0, font=MULTILINE_FONT, expand_x=True, expand_y=True, pad=(40, 40), )], |
| 142 | + [sg.Multiline(size=(LINE_LENGTH, 20), key='-OUTPUT-', border_width=0, font=MULTILINE_FONT, expand_x=True, expand_y=True, pad=(40, 40), write_only=True,)], |
141 | 143 | [sg.B('Copy to Clipboard'), sg.B('Change Theme')], ] |
142 | 144 |
|
143 | 145 | layout = [[sg.Column(column_left, expand_y=True, expand_x=False), sg.Column(column_right, expand_x=False, expand_y=False, k='-COL R-')], |
@@ -181,17 +183,18 @@ def main(): |
181 | 183 |
|
182 | 184 | while True: # Event Loop |
183 | 185 | event, values = window.read() |
184 | | - # print(event,values) |
| 186 | + print(event,values) |
185 | 187 | if event == sg.WIN_CLOSED or event == 'Exit': |
186 | 188 | break |
187 | 189 | if event == '-FONT-SIZE-': |
188 | 190 | MULTILINE_FONT = (MULTILINE_FONT[0], values['-FONT-SIZE-']) |
189 | 191 | window['-OUTPUT-'].update(font=MULTILINE_FONT) |
190 | 192 | window.refresh() |
191 | 193 | elif event == '-FONT-LIST-': |
192 | | - # first one is the selected, no multi-select allowed. |
193 | | - selected_font = fonts[values['-FONT-LIST-'][0]] |
| 194 | + #first one is the selected, no multi-select allowed. |
| 195 | + selected_font = values['-FONT-LIST-'][0] |
194 | 196 | window['-FONT-NAME-'].update(selected_font) |
| 197 | + |
195 | 198 | elif event == 'Edit Me': |
196 | 199 | sg.execute_editor(__file__) |
197 | 200 | elif event == 'File Location': |
@@ -225,7 +228,12 @@ def main(): |
225 | 228 | favorite_fonts = [] |
226 | 229 | sg.user_settings_set_entry('-favorites-', favorite_fonts) |
227 | 230 | window['-FAVORITES-'].update(values=favorite_fonts) |
228 | | - |
| 231 | + elif event == '-FILTER-': |
| 232 | + if values[event] == '': |
| 233 | + font_list = fonts |
| 234 | + else: |
| 235 | + font_list = list(font for font in fonts if values[event] in font) |
| 236 | + window['-FONT-LIST-'].update(font_list) |
229 | 237 | window.close() |
230 | 238 |
|
231 | 239 | if __name__ == '__main__': |
|
0 commit comments