Fix for missing font on debug print. Addition of font to Multiline demo program
This commit is contained in:
parent
00fa20e13b
commit
ee2a1ba22c
|
@ -1,37 +1,46 @@
|
|||
import PySimpleGUI as sg
|
||||
# import PySimpleGUIQt as sg
|
||||
|
||||
print(sg.version)
|
||||
|
||||
"""
|
||||
Demonstration of how to work with multiple colors when outputting text to a multiline element
|
||||
Demonstration of how to work with multiple colors and fonts when outputting text to a multiline element or with Debug Print
|
||||
|
||||
Copyright 2021 PySimpleGUI
|
||||
"""
|
||||
|
||||
MLINE_KEY = '-MLINE-'+sg.WRITE_ONLY_KEY
|
||||
MLINE_KEY = '-MLINE-'
|
||||
|
||||
layout = [ [sg.Text('Demonstration of Multiline Element\'s ability to show multiple colors ')],
|
||||
[sg.Multiline(size=(60,20), key=MLINE_KEY)],
|
||||
[sg.Multiline(size=(60,20), key=MLINE_KEY, reroute_cprint=True, write_only=True)],
|
||||
[sg.Input(k='-IN-')],
|
||||
[sg.B('Plain'), sg.Button('Text Blue Line'), sg.Button('Text Green Line')],
|
||||
[sg.Button('Background Blue Line'),sg.Button('Background Green Line'), sg.B('White on Green')] ]
|
||||
[sg.Button('Background Blue Line'),sg.Button('Background Green Line'), sg.B('White on Green'), sg.B('Font Courier 12')] ]
|
||||
|
||||
window = sg.Window('Demonstration of Multicolored Multline Text', layout)
|
||||
|
||||
# print = lambda *args, **kwargs: window[MLINE_KEY].print(*args, **kwargs, text_color='red')
|
||||
|
||||
mline:sg.Multiline = window[MLINE_KEY]
|
||||
while True:
|
||||
event, values = window.read() # type: (str, dict)
|
||||
print(event, values)
|
||||
sg.cprint(event, values, c='white on green', font='courier 12')
|
||||
sg.Print(event, c='white on green', font='courier 12', end='')
|
||||
sg.Print(values, c='white on red', font='Courier 12 underline italic bold', end='')
|
||||
sg.Print('')
|
||||
if event in (sg.WIN_CLOSED, 'Exit'):
|
||||
break
|
||||
if 'Text Blue' in event:
|
||||
window[MLINE_KEY].update('This is blue text\n', text_color_for_value='blue', append=True)
|
||||
mline.update('This is blue text\n', text_color_for_value='blue', append=True)
|
||||
if 'Text Green' in event:
|
||||
window[MLINE_KEY].update('This is green text\n', text_color_for_value='green', append=True)
|
||||
mline.update('This is green text\n', text_color_for_value='green', append=True)
|
||||
if 'Background Blue' in event:
|
||||
window[MLINE_KEY].update('This is Blue Background\n', background_color_for_value='blue', append=True)
|
||||
mline.update('This is Blue Background\n', background_color_for_value='blue', append=True)
|
||||
if 'Background Green' in event:
|
||||
window[MLINE_KEY].update('This is Green Background\n', background_color_for_value='green', append=True)
|
||||
mline.update('This is Green Background\n', background_color_for_value='green', append=True)
|
||||
if 'Font' in event:
|
||||
mline.update('This is Green Background\n', background_color_for_value='green', append=True, font_for_value=('Courier', 12, 'underline'))
|
||||
mline.print('\nThis is Green Background\n', c='white on green', font='Courier 12 bold ')
|
||||
if 'White on Green' in event:
|
||||
window[MLINE_KEY].update('This is white text on a green background', text_color_for_value='white', background_color_for_value='green', append=True)
|
||||
mline.update('This is white text on a green background\n', text_color_for_value='white', background_color_for_value='green', append=True)
|
||||
if event == 'Plain':
|
||||
window[MLINE_KEY].update('This is plain text with no extra coloring', append=True)
|
||||
mline.update('This is plain text with no extra coloring\n', append=True)
|
||||
window.close()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
version = __version__ = "4.43.0.9 Unreleased\nChanged get_versions string to be more clear, removed canvas from return values, cwd is automatically set to the folder of the application being launched when execute_py_file is called with cwd=None, popup_get_file changed to set parent=None if running on Mac, better Button error handling when bad Unicode chars are used or bad colors, open GitHub issue GUI - added collapse button to top section, see-through mode in test harness changed to be a toggle, font parm for multiline update print cprint for char by char font control, clipboard_set & clipboard_get, Listbox visibility fix, Tree element expansion fixed, added new element_frame convention for elements that are in frames like the Listbox and Tree (need to check the other elements and add those that have frames)"
|
||||
version = __version__ = "4.43.0.10 Unreleased\nChanged get_versions string to be more clear, removed canvas from return values, cwd is automatically set to the folder of the application being launched when execute_py_file is called with cwd=None, popup_get_file changed to set parent=None if running on Mac, better Button error handling when bad Unicode chars are used or bad colors, open GitHub issue GUI - added collapse button to top section, see-through mode in test harness changed to be a toggle, font parm for multiline update print cprint for char by char font control, clipboard_set & clipboard_get, Listbox visibility fix, Tree element expansion fixed, added new element_frame convention for elements that are in frames like the Listbox and Tree (need to check the other elements and add those that have frames), fix in debug print for font not being passed along"
|
||||
|
||||
__version__ = version.split()[0] # For PEP 396 and PEP 345
|
||||
|
||||
|
@ -14728,7 +14728,7 @@ def easy_print(*args, size=(None, None), end=None, sep=None, location=(None, Non
|
|||
no_button=no_button, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top,
|
||||
do_not_reroute_stdout=do_not_reroute_stdout, resizable=resizable)
|
||||
txt_color, bg_color = _parse_colors_parm(c or colors)
|
||||
_DebugWin.debug_window.Print(*args, end=end, sep=sep, text_color=text_color or txt_color, background_color=background_color or bg_color, erase_all=erase_all)
|
||||
_DebugWin.debug_window.Print(*args, end=end, sep=sep, text_color=text_color or txt_color, background_color=background_color or bg_color, erase_all=erase_all, font=font)
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue