I would like to build simple GUI apps based in Python that can be distributed to my co-workers. In this process, I learnt about PySimpleGUI27 for Python 2.7 version.
The following is a simple code that produces a window with menu options. I then used PyInstaller to create a build and test it out. However, when I run the .exe build from "dist" folder it just flashes and disappears. But when I run the GUI script from within a Python IDE, I am able to actually see the GUI function.
import PySimpleGUI27 as sg
sg.ChangeLookAndFeel('LightGreen')
sg.SetOptions(element_padding=(0, 0))
# ------ Menu Definition ------ #
menu_def = [['File', ['Open', 'Save', 'Exit']],
['Edit', ['Paste', ['Special', 'Normal', ], 'Undo'], ],
['Help', 'About...'], ]
# ------ GUI Definition ------ #
layout = [
[sg.Menu(menu_def, )],
[sg.Output(size=(60, 20))]
]
window = sg.Window("Windows-like program", default_element_size=(12, 1), auto_size_text=False, auto_size_buttons=False,
default_button_element_size=(12, 1)).Layout(layout)
# ------ Loop & Process button menu choices ------ #
while True:
event, values = window.Read()
if event == None or event == 'Exit':
break
print('Button = ', event)
# ------ Process menu choices ------ #
if event == 'About...':
sg.Popup('About this program', 'Version: 1.0', 'PyDist: Anaconda27')
elif event == 'Open':
filename = sg.PopupGetFile('file to open', no_window=True)
print(filename)
GUI generated when I run the script
When I try to run the exe file, it flashes and disappears. Please check out the awesome GIF here. Any advise is appreciated.
Running the EXE from the folder using Powershell.
PS C:\Users\user\AppData\Local\Continuum\anaconda3\envs\XCAL\Scripts\dist\PySimpleGUI_00> .\PySimpleGUI_00.exe
Traceback (most recent call last):
File "PySimpleGUI_00.py", line 1, in <module>
File "c:\users\user\appdata\local\temp\pip-install-qrr1qq\PyInstaller\PyInstaller\loader\pyimod03_importers.py", line 395, in load_module
File "site-packages\PySimpleGUI27\__init__.py", line 2, in <module>
File "c:\users\user\appdata\local\temp\pip-install-qrr1qq\PyInstaller\PyInstaller\loader\pyimod03_importers.py", line 395, in load_module
File "site-packages\PySimpleGUI27\PySimpleGUI27.py", line 13, in <module>
File "site-packages\future\standard_library\__init__.py", line 459, in install_aliases
ImportError: No module named UserList
[15328] Failed to execute script PySimpleGUI_00