Skip to content
39 changes: 27 additions & 12 deletions PySimpleGUI.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python3
version = __version__ = "4.53.0.15 Unreleased"
version = __version__ = "4.53.0.19 Unreleased"

_change_log = """
Changelog since 4.53.0 released to PyPI on 24-Oct-2021
Expand Down Expand Up @@ -55,6 +55,15 @@
HUGE thank you to Jason for helping with this!
4.53.0.15
More work on the right click menus for tabgroups. Need to always set one so that callback occurs
4.53.0.16
Fixed crash in the github upgrade thread that was due to Exec API changing to combine stdout and stderr by default
4.53.0.17
Changed the psgmain and psgupgrade code to relaunch using the version of Python used to call those functions
It was using the settings file to get the Python version and should instead use whatever was used to invoke PySimpleGUI
4.53.0.18
Changed the _copy_files_from_github code to always use the currently running python interpreter to do the pip install!
4.53.0.19
Removed the print in the relauch of psgmain.... struggling a bit with the whole psgmain upgrading itself....
"""

__version__ = version.split()[0] # For PEP 396 and PEP 345
Expand Down Expand Up @@ -22155,15 +22164,17 @@ def _the_github_upgrade_thread(window, sp):
"""

window.write_event_value('-THREAD-', (sp, '===THEAD STARTING==='))
window.write_event_value('-THREAD-', (sp, '----- STDOUT Follows ----'))
window.write_event_value('-THREAD-', (sp, '----- STDOUT & STDERR Follows ----'))
for line in sp.stdout:
oline = line.decode().rstrip()
window.write_event_value('-THREAD-', (sp, oline))
window.write_event_value('-THREAD-', (sp, '----- STDERR ----'))

for line in sp.stderr:
oline = line.decode().rstrip()
window.write_event_value('-THREAD-', (sp, oline))
# DO NOT CHECK STDERR because it won't exist anymore. The subprocess code now combines stdout and stderr
# window.write_event_value('-THREAD-', (sp, '----- STDERR ----'))

# for line in sp.stderr:
# oline = line.decode().rstrip()
# window.write_event_value('-THREAD-', (sp, oline))
window.write_event_value('-THREAD-', (sp, '===THEAD DONE==='))


Expand Down Expand Up @@ -22238,7 +22249,8 @@ def _copy_files_from_github():
# install the pysimplegui package from local dist
# https://pip.pypa.io/en/stable/user_guide/?highlight=subprocess#using-pip-from-your-program
# subprocess.check_call([sys.executable, '-m', 'pip', 'install', path])
python_command = execute_py_get_interpreter()
# python_command = execute_py_get_interpreter()
python_command = sys.executable # always use the currently running interpreter to perform the pip!

layout = [[Text('Pip Upgrade Progress')],
[Multiline(s=(90,30), k='-MLINE-', reroute_cprint=True, write_only=True)],
Expand All @@ -22248,8 +22260,8 @@ def _copy_files_from_github():

cprint('The value of sys.executable = ', sys.executable, c='white on red')

if not python_command:
python_command = sys.executable
# if not python_command:
# python_command = sys.executable

cprint('Installing with the Python interpreter =', python_command, c='white on purple')

Expand Down Expand Up @@ -22314,11 +22326,14 @@ def _upgrade_entry_point():
It simply runs the PySimpleGUI.py file with a command line argument "upgrade" which will
actually do the upgrade.
"""
execute_py_file(__file__, 'upgrade')
execute_py_file(__file__, 'upgrade', interpreter_command=sys.executable)



def _main_entry_point():
print('Restarting main as a new process...(needed in case you want to GitHub Upgrade)')
execute_py_file(__file__)
# print('Restarting main as a new process...(needed in case you want to GitHub Upgrade)')
# Relaunch using the same python interpreter that was used to run this function
execute_py_file(__file__, interpreter_command=sys.executable)

main_upgrade_from_github = _upgrade_entry_point

Expand Down