commit
ffd86889e0
|
@ -40,7 +40,7 @@ def get_demo_git_files():
|
||||||
:rtype: Tuple[List[str], List[str]]
|
:rtype: Tuple[List[str], List[str]]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
demo_path = sg.user_settings_get_entry('-demos folder-', '.')
|
demo_path = get_demo_path()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
demo_files = os.listdir(demo_path)
|
demo_files = os.listdir(demo_path)
|
||||||
|
@ -50,6 +50,29 @@ def get_demo_git_files():
|
||||||
return demo_files
|
return demo_files
|
||||||
|
|
||||||
|
|
||||||
|
def get_demo_path():
|
||||||
|
demo_path = sg.user_settings_get_entry('-demos folder-', os.path.dirname(__file__))
|
||||||
|
|
||||||
|
return demo_path
|
||||||
|
|
||||||
|
|
||||||
|
def get_editor():
|
||||||
|
try: # in case running with old version of PySimpleGUI that doesn't have a global PSG settings path
|
||||||
|
if sg.pysimplegui_user_settings:
|
||||||
|
global_editor = sg.pysimplegui_user_settings.get('-editor program-')
|
||||||
|
else:
|
||||||
|
global_editor = ''
|
||||||
|
except:
|
||||||
|
global_editor = ''
|
||||||
|
|
||||||
|
return sg.user_settings_get_entry('-editor program-', global_editor)
|
||||||
|
|
||||||
|
|
||||||
|
def get_theme():
|
||||||
|
global_theme = sg.theme()
|
||||||
|
|
||||||
|
return sg.user_settings_get_entry('-theme-', global_theme)
|
||||||
|
|
||||||
def find_in_file(string):
|
def find_in_file(string):
|
||||||
"""
|
"""
|
||||||
Search through the demo files for a string.
|
Search through the demo files for a string.
|
||||||
|
@ -60,7 +83,7 @@ def find_in_file(string):
|
||||||
:rtype: List[str]
|
:rtype: List[str]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
demo_path = sg.user_settings_get_entry('-demos folder-')
|
demo_path = get_demo_path()
|
||||||
demo_files = get_demo_git_files()
|
demo_files = get_demo_git_files()
|
||||||
string = string.lower()
|
string = string.lower()
|
||||||
file_list = []
|
file_list = []
|
||||||
|
@ -88,11 +111,13 @@ def settings_window():
|
||||||
:rtype: (bool)
|
:rtype: (bool)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
editor_program = get_editor()
|
||||||
|
|
||||||
layout = [[sg.T('Program Settings', font='DEFAIULT 18')],
|
layout = [[sg.T('Program Settings', font='DEFAIULT 18')],
|
||||||
[sg.T('Path to Demos', size=(20,1)), sg.In(sg.user_settings_get_entry('-demos folder-', '.'), k='-DEMOS-'), sg.FolderBrowse()],
|
[sg.T('Path to Demos', size=(20,1)), sg.In(sg.user_settings_get_entry('-demos folder-', '.'), k='-DEMOS-'), sg.FolderBrowse()],
|
||||||
[sg.T('Editor Program', size=(20,1)), sg.In(sg.user_settings_get_entry('-Editor Program-', ''),k='-EDITOR PROGRAM-'), sg.FileBrowse()],
|
[sg.T('Editor Program', size=(20,1)), sg.In(sg.user_settings_get_entry('-editor program-', editor_program),k='-EDITOR PROGRAM-'), sg.FileBrowse()],
|
||||||
[sg.T(r"For PyCharm, Add this to your PyCharm main program's folder \bin\pycharm.bat")],
|
[sg.T(r"For PyCharm, Add this to your PyCharm main program's folder \bin\pycharm.bat")],
|
||||||
[sg.Combo(sg.theme_list(), sg.user_settings_get_entry('-theme-', None), k='-THEME-')],
|
[sg.Combo(['']+sg.theme_list(), sg.user_settings_get_entry('-theme-', None), k='-THEME-')],
|
||||||
[sg.B('Ok', bind_return_key=True), sg.B('Cancel')],
|
[sg.B('Ok', bind_return_key=True), sg.B('Cancel')],
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -100,8 +125,10 @@ def settings_window():
|
||||||
event, values = window.read(close=True)
|
event, values = window.read(close=True)
|
||||||
if event == 'Ok':
|
if event == 'Ok':
|
||||||
sg.user_settings_set_entry('-demos folder-', values['-DEMOS-'])
|
sg.user_settings_set_entry('-demos folder-', values['-DEMOS-'])
|
||||||
sg.user_settings_set_entry('-Editor Program-', values['-EDITOR PROGRAM-'])
|
new_editor = global_editor if not values['-EDITOR PROGRAM-'] else values['-EDITOR PROGRAM-']
|
||||||
sg.user_settings_set_entry('-theme-', values['-THEME-'])
|
sg.user_settings_set_entry('-editor program-', new_editor)
|
||||||
|
new_theme = sg.theme_global() if values['-THEME-'] == '' else values['-THEME-']
|
||||||
|
sg.user_settings_set_entry('-theme-', new_theme)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
@ -114,7 +141,8 @@ def make_window():
|
||||||
:rtype: (Window)
|
:rtype: (Window)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
theme = sg.user_settings_get_entry('-theme-')
|
theme = get_theme()
|
||||||
|
editor = get_editor()
|
||||||
demo_files = get_demo_git_files()
|
demo_files = get_demo_git_files()
|
||||||
if not theme:
|
if not theme:
|
||||||
theme = sg.OFFICIAL_PYSIMPLEGUI_THEME
|
theme = sg.OFFICIAL_PYSIMPLEGUI_THEME
|
||||||
|
@ -159,10 +187,9 @@ def main():
|
||||||
It will call the make_window function to create the window.
|
It will call the make_window function to create the window.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
demo_path = sg.user_settings_get_entry('-demos folder-', '.')
|
demo_path = get_demo_path()
|
||||||
editor_program = sg.user_settings_get_entry('-Editor Program-', '')
|
editor_program = get_editor()
|
||||||
demo_files = get_demo_git_files()
|
demo_files = get_demo_git_files()
|
||||||
|
|
||||||
window = make_window()
|
window = make_window()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
@ -171,12 +198,12 @@ def main():
|
||||||
break
|
break
|
||||||
if event == 'Edit':
|
if event == 'Edit':
|
||||||
for file in values['-DEMO LIST-']:
|
for file in values['-DEMO LIST-']:
|
||||||
sg.cprint(f'opening (in editor)', text_color='white', background_color='red', end='')
|
sg.cprint(f'Editing using {editor_program}', text_color='white', background_color='red', end='')
|
||||||
sg.cprint('')
|
sg.cprint('')
|
||||||
sg.cprint(f'{os.path.join(demo_path, file)}', text_color='white', background_color='purple')
|
sg.cprint(f'{os.path.join(demo_path, file)}', text_color='white', background_color='purple')
|
||||||
execute_command_subprocess(f'{editor_program}', os.path.join(demo_path, file))
|
execute_command_subprocess(f'{editor_program}', os.path.join(demo_path, file))
|
||||||
elif event == 'Run':
|
elif event == 'Run':
|
||||||
sg.cprint('Running Demo Programs....', c='white on green', end='')
|
sg.cprint('Running....', c='white on green', end='')
|
||||||
sg.cprint('')
|
sg.cprint('')
|
||||||
for file in values['-DEMO LIST-']:
|
for file in values['-DEMO LIST-']:
|
||||||
sg.cprint(os.path.join(demo_path, file),text_color='white', background_color='purple')
|
sg.cprint(os.path.join(demo_path, file),text_color='white', background_color='purple')
|
||||||
|
@ -200,9 +227,10 @@ def main():
|
||||||
if settings_window() is True:
|
if settings_window() is True:
|
||||||
window.close()
|
window.close()
|
||||||
window = make_window()
|
window = make_window()
|
||||||
demo_path = sg.user_settings_get_entry('-demos folder-')
|
demo_path = get_demo_path()
|
||||||
editor_program = sg.user_settings_get_entry('-Editor Program-')
|
editor_program = get_editor()
|
||||||
demo_files = get_demo_git_files()
|
demo_files = get_demo_git_files()
|
||||||
|
theme = get_theme()
|
||||||
elif event == 'Clear':
|
elif event == 'Clear':
|
||||||
window['-FILTER-'].update('')
|
window['-FILTER-'].update('')
|
||||||
window['-FIND-'].update('')
|
window['-FIND-'].update('')
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
version = __version__ = "4.34.0.9 Unreleased\nSDK Help Expanded to init & update parms, SDK Help function search, files_delimiter added to FilesBrowse & popup_get_file, SDK help sort by case, popup_get_file fixed default_extension not being passed to button correctly, changed themes so that spaces can be used in defined name, addition of subprocess non-blocking launcher, fix for Debug button color, set_option for default user_settings path to override normal default, define a truly global PySimpleGUI settings path"
|
version = __version__ = "4.34.0.9 Unreleased\nSDK Help Expanded to init & update parms, SDK Help function search, files_delimiter added to FilesBrowse & popup_get_file, SDK help sort by case, popup_get_file fixed default_extension not being passed to button correctly, changed themes so that spaces can be used in defined name, addition of subprocess non-blocking launcher, fix for Debug button color, set_option for default user_settings path to override normal default, define a truly global PySimpleGUI settings path, theme_global() gets the theme for all progams"
|
||||||
|
|
||||||
__version__ = version.split()[0] # For PEP 396 and PEP 345
|
__version__ = version.split()[0] # For PEP 396 and PEP 345
|
||||||
|
|
||||||
|
@ -542,6 +542,7 @@ DEFAULT_USER_SETTINGS_MAC_PATH =r'~/Library/Application Support/PySimpleGUI/sett
|
||||||
DEFAULT_USER_SETTINGS_UNKNOWN_OS_PATH =r'~/Library/Application Support/PySimpleGUI/settings'
|
DEFAULT_USER_SETTINGS_UNKNOWN_OS_PATH =r'~/Library/Application Support/PySimpleGUI/settings'
|
||||||
DEFAULT_USER_SETTINGS_PATH = None # value set by user to override all paths above
|
DEFAULT_USER_SETTINGS_PATH = None # value set by user to override all paths above
|
||||||
DEFAULT_USER_SETTINGS_PYSIMPLEGUI_PATH = None # location of the global PySimpleGUI settings
|
DEFAULT_USER_SETTINGS_PYSIMPLEGUI_PATH = None # location of the global PySimpleGUI settings
|
||||||
|
DEFAULT_USER_SETTINGS_PYSIMPLEGUI_FILENAME = '_PySimpleGUI_settings_global_.json' # location of the global PySimpleGUI settings
|
||||||
|
|
||||||
# ====================================================================== #
|
# ====================================================================== #
|
||||||
# One-liner functions that are handy as f_ck #
|
# One-liner functions that are handy as f_ck #
|
||||||
|
@ -14201,7 +14202,7 @@ def set_options(icon=None, button_color=None, element_size=(None, None), button_
|
||||||
text_justification=None, background_color=None, element_background_color=None,
|
text_justification=None, background_color=None, element_background_color=None,
|
||||||
text_element_background_color=None, input_elements_background_color=None, input_text_color=None,
|
text_element_background_color=None, input_elements_background_color=None, input_text_color=None,
|
||||||
scrollbar_color=None, text_color=None, element_text_color=None, debug_win_size=(None, None),
|
scrollbar_color=None, text_color=None, element_text_color=None, debug_win_size=(None, None),
|
||||||
window_location=(None, None), error_button_color=(None, None), tooltip_time=None, tooltip_font=None, use_ttk_buttons=None, ttk_theme=None, suppress_error_popups=None, suppress_raise_key_errors=None, suppress_key_guessing=None, enable_treeview_869_patch=None, enable_mac_notitlebar_patch=None, use_custom_titlebar=None, titlebar_background_color=None, titlebar_text_color=None, titlebar_font=None, titlebar_icon=None, user_settings_path=None, pysimplegui_settings_path=None):
|
window_location=(None, None), error_button_color=(None, None), tooltip_time=None, tooltip_font=None, use_ttk_buttons=None, ttk_theme=None, suppress_error_popups=None, suppress_raise_key_errors=None, suppress_key_guessing=None, enable_treeview_869_patch=None, enable_mac_notitlebar_patch=None, use_custom_titlebar=None, titlebar_background_color=None, titlebar_text_color=None, titlebar_font=None, titlebar_icon=None, user_settings_path=None, pysimplegui_settings_path=None, pysimplegui_settings_filename=None):
|
||||||
"""
|
"""
|
||||||
:param icon: filename or base64 string to be used for the window's icon
|
:param icon: filename or base64 string to be used for the window's icon
|
||||||
:type icon: bytes | str
|
:type icon: bytes | str
|
||||||
|
@ -14299,6 +14300,8 @@ def set_options(icon=None, button_color=None, element_size=(None, None), button_
|
||||||
:type user_settings_path: (str)
|
:type user_settings_path: (str)
|
||||||
:param pysimplegui_settings_path: default path for the global PySimpleGUI user_settings
|
:param pysimplegui_settings_path: default path for the global PySimpleGUI user_settings
|
||||||
:type pysimplegui_settings_path: (str)
|
:type pysimplegui_settings_path: (str)
|
||||||
|
:param pysimplegui_settings_filename: default filename for the global PySimpleGUI user_settings
|
||||||
|
:type pysimplegui_settings_filename: (str)
|
||||||
:return: None
|
:return: None
|
||||||
:rtype: None
|
:rtype: None
|
||||||
"""
|
"""
|
||||||
|
@ -14350,7 +14353,8 @@ def set_options(icon=None, button_color=None, element_size=(None, None), button_
|
||||||
global CUSTOM_TITLEBAR_FONT
|
global CUSTOM_TITLEBAR_FONT
|
||||||
global DEFAULT_USER_SETTINGS_PATH
|
global DEFAULT_USER_SETTINGS_PATH
|
||||||
global DEFAULT_USER_SETTINGS_PYSIMPLEGUI_PATH
|
global DEFAULT_USER_SETTINGS_PYSIMPLEGUI_PATH
|
||||||
|
global DEFAULT_USER_SETTINGS_PYSIMPLEGUI_FILENAME
|
||||||
|
global _pysimplegui_user_settings
|
||||||
# global _my_windows
|
# global _my_windows
|
||||||
|
|
||||||
if icon:
|
if icon:
|
||||||
|
@ -14499,6 +14503,13 @@ def set_options(icon=None, button_color=None, element_size=(None, None), button_
|
||||||
if pysimplegui_settings_path is not None:
|
if pysimplegui_settings_path is not None:
|
||||||
DEFAULT_USER_SETTINGS_PYSIMPLEGUI_PATH = pysimplegui_settings_path
|
DEFAULT_USER_SETTINGS_PYSIMPLEGUI_PATH = pysimplegui_settings_path
|
||||||
|
|
||||||
|
if pysimplegui_settings_filename is not None:
|
||||||
|
DEFAULT_USER_SETTINGS_PYSIMPLEGUI_FILENAME = pysimplegui_settings_filename
|
||||||
|
|
||||||
|
if pysimplegui_settings_filename is not None or pysimplegui_settings_filename is not None:
|
||||||
|
_pysimplegui_user_settings = UserSettings(filename=DEFAULT_USER_SETTINGS_PYSIMPLEGUI_FILENAME,
|
||||||
|
path=DEFAULT_USER_SETTINGS_PYSIMPLEGUI_PATH)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -14895,6 +14906,20 @@ def theme_add_new(new_theme_name, new_theme_dict):
|
||||||
print('Exception during adding new theme {}'.format(e))
|
print('Exception during adding new theme {}'.format(e))
|
||||||
|
|
||||||
|
|
||||||
|
def theme_global(new_theme=None):
|
||||||
|
"""
|
||||||
|
Sets / Gets the global PySimpleGUI Theme. If none is specified then returns the global theme from user settings
|
||||||
|
|
||||||
|
:param new_theme: the new theme name to use
|
||||||
|
:type new_theme: (str)
|
||||||
|
:return: the currently selected theme
|
||||||
|
:rtype: (str)
|
||||||
|
"""
|
||||||
|
if new_theme is not None:
|
||||||
|
pysimplegui_user_settings.set('-theme-', new_theme)
|
||||||
|
return new_theme
|
||||||
|
else:
|
||||||
|
return pysimplegui_user_settings.get('-theme-', CURRENT_LOOK_AND_FEEL)
|
||||||
|
|
||||||
|
|
||||||
def theme_previewer(columns=12, scrollable=False, scroll_area_size=(None, None), search_string=None, location=(None, None)):
|
def theme_previewer(columns=12, scrollable=False, scroll_area_size=(None, None), search_string=None, location=(None, None)):
|
||||||
|
@ -17104,13 +17129,15 @@ class UserSettings:
|
||||||
:type key: (Any)
|
:type key: (Any)
|
||||||
:param value: Value to save as the setting's value. Can be anything
|
:param value: Value to save as the setting's value. Can be anything
|
||||||
:type value: (Any)
|
:type value: (Any)
|
||||||
|
:return: value that key was set to
|
||||||
|
:rtype: (Any)
|
||||||
"""
|
"""
|
||||||
if self.full_filename is None:
|
if self.full_filename is None:
|
||||||
self.set_location()
|
self.set_location()
|
||||||
self.read()
|
self.read()
|
||||||
self.dict[key] = value
|
self.dict[key] = value
|
||||||
self.save()
|
self.save()
|
||||||
|
return value
|
||||||
|
|
||||||
def get(self, key, default=None):
|
def get(self, key, default=None):
|
||||||
"""
|
"""
|
||||||
|
@ -18229,6 +18256,35 @@ def main_get_debug_data(suppress_popup=False):
|
||||||
|
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
def main_global_pysimplegui_settings():
|
||||||
|
"""
|
||||||
|
Window to set settings that will be used across all PySimpleGUI programs that choose to use them.
|
||||||
|
Use set_options to set the path to the folder for all PySimpleGUI settings.
|
||||||
|
|
||||||
|
:return: True if settings were changed
|
||||||
|
:rtype: (bool)
|
||||||
|
"""
|
||||||
|
|
||||||
|
settings = pysimplegui_user_settings.read()
|
||||||
|
|
||||||
|
layout = [[T('Global PySimpleGUI Settings', font='DEFAIULT 18')],
|
||||||
|
[T('Editor Program', size=(20,1)), In(settings.get('-editor program-', ''),k='-EDITOR PROGRAM-'), FileBrowse()],
|
||||||
|
[T(r"For PyCharm, Add this to your PyCharm main program's folder \bin\pycharm.bat")],
|
||||||
|
[T('Default Theme For All Programs:'), Combo([''] + theme_list(), settings.get('-theme-', None), k='-THEME-')],
|
||||||
|
[B('Ok', bind_return_key=True), B('Cancel')],
|
||||||
|
]
|
||||||
|
|
||||||
|
window = Window('Settings', layout, keep_on_top=True)
|
||||||
|
event, values = window.read(close=True)
|
||||||
|
if event == 'Ok':
|
||||||
|
new_theme = OFFICIAL_PYSIMPLEGUI_THEME if values['-THEME-'] == '' else values['-THEME-']
|
||||||
|
pysimplegui_user_settings.set('-editor program-', values['-EDITOR PROGRAM-'])
|
||||||
|
pysimplegui_user_settings.set('-theme-', new_theme)
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main_sdk_help():
|
def main_sdk_help():
|
||||||
"""
|
"""
|
||||||
Display a window that will display the docstrings for each PySimpleGUI Element and the Window object
|
Display a window that will display the docstrings for each PySimpleGUI Element and the Window object
|
||||||
|
@ -18498,6 +18554,7 @@ I hope you are enjoying using PySimpleGUI whether you sponsor the product or not
|
||||||
Button('ttk Button', use_ttk_buttons=True, tooltip='This is a TTK Button'),
|
Button('ttk Button', use_ttk_buttons=True, tooltip='This is a TTK Button'),
|
||||||
Button('See-through Mode', tooltip='Make the background transparent'),
|
Button('See-through Mode', tooltip='Make the background transparent'),
|
||||||
Button('Upgrade PySimpleGUI from GitHub', button_color='white on red', key='-INSTALL-'),
|
Button('Upgrade PySimpleGUI from GitHub', button_color='white on red', key='-INSTALL-'),
|
||||||
|
Button('Global Settings', tooltip='Settings across all PySimpleGUI programs'),
|
||||||
Button('Exit', tooltip='Exit button')],
|
Button('Exit', tooltip='Exit button')],
|
||||||
[ B(image_data=ICON_BUY_ME_A_COFFEE, key='-COFFEE-'),
|
[ B(image_data=ICON_BUY_ME_A_COFFEE, key='-COFFEE-'),
|
||||||
B('Themes'), B('Theme Swatches'), B('Switch Themes'),B('SDK Reference'), B('Info for GitHub'),
|
B('Themes'), B('Theme Swatches'), B('Switch Themes'),B('SDK Reference'), B('Info for GitHub'),
|
||||||
|
@ -18592,6 +18649,12 @@ def main():
|
||||||
window['-HIDE TABS-'].update(text=SYMBOL_UP if window['-TAB GROUP-'].metadata else SYMBOL_DOWN)
|
window['-HIDE TABS-'].update(text=SYMBOL_UP if window['-TAB GROUP-'].metadata else SYMBOL_DOWN)
|
||||||
elif event == 'SDK Reference':
|
elif event == 'SDK Reference':
|
||||||
main_sdk_help()
|
main_sdk_help()
|
||||||
|
elif event == 'Global Settings':
|
||||||
|
if main_global_pysimplegui_settings():
|
||||||
|
theme(pysimplegui_user_settings.get('-theme-', OFFICIAL_PYSIMPLEGUI_THEME))
|
||||||
|
window.close()
|
||||||
|
window = _create_main_window()
|
||||||
|
graph_elem = window['+GRAPH+']
|
||||||
elif event.startswith('P '):
|
elif event.startswith('P '):
|
||||||
if event == 'P ':
|
if event == 'P ':
|
||||||
popup('Normal Popup - Modal', keep_on_top=True)
|
popup('Normal Popup - Modal', keep_on_top=True)
|
||||||
|
@ -18663,9 +18726,10 @@ TimerStop = timer_stop
|
||||||
test = main
|
test = main
|
||||||
sdk_help = main_sdk_help
|
sdk_help = main_sdk_help
|
||||||
|
|
||||||
|
pysimplegui_user_settings = UserSettings(filename=DEFAULT_USER_SETTINGS_PYSIMPLEGUI_FILENAME, path=DEFAULT_USER_SETTINGS_PYSIMPLEGUI_PATH)
|
||||||
#------------------------ Set the "Official PySimpleGUI Theme Colors" ------------------------
|
#------------------------ Set the "Official PySimpleGUI Theme Colors" ------------------------
|
||||||
theme(CURRENT_LOOK_AND_FEEL)
|
|
||||||
|
theme(theme_global())
|
||||||
|
|
||||||
# See if running on Trinket. If Trinket, then use custom titlebars since Trinket doesn't supply any
|
# See if running on Trinket. If Trinket, then use custom titlebars since Trinket doesn't supply any
|
||||||
if _running_trinket():
|
if _running_trinket():
|
||||||
|
|
Loading…
Reference in New Issue