Merge pull request #4951 from PySimpleGUI/Dev-latest

SDK Reference - changed to inspect.getfullargspec because inspect.get…
This commit is contained in:
PySimpleGUI 2021-11-10 12:04:52 -05:00 committed by GitHub
commit 9c2f547f31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 75 additions and 72 deletions

View File

@ -1,12 +1,14 @@
#!/usr/bin/python3 #!/usr/bin/python3
version = __version__ = "4.55.1.1 Released 7-Nov-2021" version = __version__ = "4.55.1.2 Unreleased"
_change_log = """ _change_log = """
Changelog since 4.55.1 released to PyPI on 7-Nov-2021 Changelog since 4.55.1 released to PyPI on 7-Nov-2021
4.55.1.1 4.55.1.1
Addition of stdin parm to execute_command_subprocess. This is to fix problem when pyinstaller is used to make an EXE from a psg program that calls this function Addition of stdin parm to execute_command_subprocess. This is to fix problem when pyinstaller is used to make an EXE from a psg program that calls this function
4.55.1.2
Changed getargspec call in the SDK Reference window to getfullargspec. In 3.11 getargspec is no longer supported and thus crashes
Added try to SDK Reference event loop to catch any additional problems that may pop up in 3.11
""" """
__version__ = version.split()[0] # For PEP 396 and PEP 345 __version__ = version.split()[0] # For PEP 396 and PEP 345
@ -169,11 +171,10 @@ try:
except: except:
webbrowser_available = False webbrowser_available = False
# used for github upgrades # used for github upgrades
import sys
import urllib.request import urllib.request
import urllib.error import urllib.error
import urllib.parse import urllib.parse
import pydoc
from urllib import request from urllib import request
import os import os
import sys import sys
@ -22546,8 +22547,8 @@ def main_sdk_help():
for element in element_classes: for element in element_classes:
# Build info about init method # Build info about init method
args = inspect.getargspec(element.__init__).args[1:] args = inspect.getfullargspec(element.__init__).args[1:]
defaults = inspect.getargspec(element.__init__).defaults defaults = inspect.getfullargspec(element.__init__).defaults
# print('------------- {element}----------') # print('------------- {element}----------')
# print(args) # print(args)
# print(defaults) # print(defaults)
@ -22561,8 +22562,8 @@ def main_sdk_help():
# Build info about update method # Build info about update method
try: try:
args = inspect.getargspec(element.update).args[1:] args = inspect.getfullargspec(element.update).args[1:]
defaults = inspect.getargspec(element.update).defaults defaults = inspect.getfullargspec(element.update).defaults
if args is None or defaults is None: if args is None or defaults is None:
element_arg_default_dict_update[element.__name__] = (('', ''),) element_arg_default_dict_update[element.__name__] = (('', ''),)
continue continue
@ -22594,76 +22595,78 @@ def main_sdk_help():
online_help_link = '' online_help_link = ''
ml = window['-ML-'] ml = window['-ML-']
current_element = '' current_element = ''
while True: # Event Loop try:
event, values = window.read() while True: # Event Loop
if event in (WIN_CLOSED, 'Exit'): event, values = window.read()
break if event in (WIN_CLOSED, 'Exit'):
if event == '-DOC LINK-': break
if webbrowser_available and online_help_link: if event == '-DOC LINK-':
webbrowser.open_new_tab(online_help_link) if webbrowser_available and online_help_link:
if event == '-SUMMARY-': webbrowser.open_new_tab(online_help_link)
event = current_element if event == '-SUMMARY-':
event = current_element
if event in element_names.keys(): if event in element_names.keys():
current_element = event current_element = event
window['-ML-'].update('') window['-ML-'].update('')
online_help_link = online_help_links.get(event, '') online_help_link = online_help_links.get(event, '')
window['-DOC LINK-'].update(online_help_link) window['-DOC LINK-'].update(online_help_link)
if not values['-SUMMARY-']: if not values['-SUMMARY-']:
elem = element_names[event] elem = element_names[event]
ml.print(help(elem)) ml.print(pydoc.help(elem))
# print the aliases for the class # print the aliases for the class
ml.print('\n--- Shortcut Aliases for Class ---') ml.print('\n--- Shortcut Aliases for Class ---')
for v in vars3: for v in vars3:
if elem == v[1] and elem.__name__ != v[0]: if elem == v[1] and elem.__name__ != v[0]:
print(v[0]) print(v[0])
ml.print('\n--- Init Parms ---') ml.print('\n--- Init Parms ---')
else: else:
elem = element_names[event] elem = element_names[event]
element_methods = [m[0] for m in inspect.getmembers(Element, inspect.isfunction) if not m[0].startswith('_') and not m[0][0].isupper()] element_methods = [m[0] for m in inspect.getmembers(Element, inspect.isfunction) if not m[0].startswith('_') and not m[0][0].isupper()]
methods = inspect.getmembers(elem, inspect.isfunction) methods = inspect.getmembers(elem, inspect.isfunction)
methods = [m[0] for m in methods if not m[0].startswith('_') and not m[0][0].isupper()] methods = [m[0] for m in methods if not m[0].startswith('_') and not m[0][0].isupper()]
unique_methods = [m for m in methods if m not in element_methods and not m[0][0].isupper()] unique_methods = [m for m in methods if m not in element_methods and not m[0][0].isupper()]
properties = inspect.getmembers(elem, lambda o: isinstance(o, property)) properties = inspect.getmembers(elem, lambda o: isinstance(o, property))
properties = [p[0] for p in properties if not p[0].startswith('_')] properties = [p[0] for p in properties if not p[0].startswith('_')]
ml.print('--- Methods ---', background_color='red', text_color='white') ml.print('--- Methods ---', background_color='red', text_color='white')
ml.print('\n'.join(methods)) ml.print('\n'.join(methods))
ml.print('--- Properties ---', background_color='red', text_color='white') ml.print('--- Properties ---', background_color='red', text_color='white')
ml.print('\n'.join(properties)) ml.print('\n'.join(properties))
if issubclass(elem, Element): if issubclass(elem, Element):
ml.print('Methods Unique to This Element', background_color='red', text_color='white') ml.print('Methods Unique to This Element', background_color='red', text_color='white')
ml.print('\n'.join(unique_methods)) ml.print('\n'.join(unique_methods))
ml.print('========== Init Parms ==========', background_color='#FFFF00', text_color='black') ml.print('========== Init Parms ==========', background_color='#FFFF00', text_color='black')
elem_text_name = event elem_text_name = event
for parm, default in element_arg_default_dict[elem_text_name]: for parm, default in element_arg_default_dict[elem_text_name]:
ml.print('{:18}'.format(parm), end=' = ')
ml.print(default, end=',\n')
if elem_text_name in element_arg_default_dict_update:
ml.print('========== Update Parms ==========', background_color='#FFFF00', text_color='black')
for parm, default in element_arg_default_dict_update[elem_text_name]:
ml.print('{:18}'.format(parm), end=' = ') ml.print('{:18}'.format(parm), end=' = ')
ml.print(default, end=',\n') ml.print(default, end=',\n')
ml.set_vscroll_position(0) # scroll to top of multoline if elem_text_name in element_arg_default_dict_update:
elif event == 'Func Search': ml.print('========== Update Parms ==========', background_color='#FFFF00', text_color='black')
search_string = popup_get_text('Search for this in function list:', keep_on_top=True) for parm, default in element_arg_default_dict_update[elem_text_name]:
if search_string is not None: ml.print('{:18}'.format(parm), end=' = ')
online_help_link = '' ml.print(default, end=',\n')
window['-DOC LINK-'].update('') ml.set_vscroll_position(0) # scroll to top of multoline
ml.update('') elif event == 'Func Search':
for f_entry in functions_names: search_string = popup_get_text('Search for this in function list:', keep_on_top=True)
f = f_entry[0] if search_string is not None:
if search_string in f.lower() and not f.startswith('_'): online_help_link = ''
if (values['-PEP8-'] and not f[0].isupper()) or not values['-PEP8-']: window['-DOC LINK-'].update('')
if values['-SUMMARY-']: ml.update('')
ml.print(f) for f_entry in functions_names:
else: f = f_entry[0]
ml.print('=========== ' + f + '===========', background_color='#FFFF00', text_color='black') if search_string in f.lower() and not f.startswith('_'):
ml.print(help(f_entry[1])) if (values['-PEP8-'] and not f[0].isupper()) or not values['-PEP8-']:
ml.set_vscroll_position(0) # scroll to top of multoline if values['-SUMMARY-']:
ml.print(f)
else:
ml.print('=========== ' + f + '===========', background_color='#FFFF00', text_color='black')
ml.print(pydoc.help(f_entry[1]))
ml.set_vscroll_position(0) # scroll to top of multoline
except Exception as e:
_error_popup_with_traceback('Exception in SDK reference', e)
window.close() window.close()