Major update of all demo programs to use new PEP8 bindings, etc
This commit is contained in:
parent
3f7c87c562
commit
7f52778bcc
307 changed files with 19546 additions and 3297 deletions
|
@ -4,72 +4,79 @@ from shutil import copyfile
|
|||
import shutil
|
||||
import os
|
||||
|
||||
def Launcher():
|
||||
sg.ChangeLookAndFeel('LightGreen')
|
||||
'''
|
||||
Make a "Windows os" executable with PyInstaller
|
||||
'''
|
||||
|
||||
layout = [[sg.T('PyInstaller EXE Creator', font='Any 15')],
|
||||
[sg.T('Source Python File'), sg.In(key='_sourcefile_', size=(45,1)), sg.FileBrowse(file_types=(("Python Files", "*.py"),))],
|
||||
[sg.T('Icon File'), sg.In(key='_iconfile_', size=(45,1)), sg.FileBrowse(file_types=(("Icon Files", "*.ico"),))],
|
||||
[sg.Frame('Output', font='Any 15',layout= [[sg.Output(size=(65, 15), font='Courier 10')]])],
|
||||
[sg.ReadFormButton('Make EXE',bind_return_key=True),
|
||||
sg.SimpleButton('Quit', button_color=('white','firebrick3')),]]
|
||||
def Launcher():
|
||||
sg.change_look_and_feel('LightGreen')
|
||||
|
||||
layout = [[sg.Text('PyInstaller EXE Creator', font='Any 15')],
|
||||
[sg.Text('Source Python File'), sg.Input(key='-sourcefile-', size=(45, 1)),
|
||||
sg.FileBrowse(file_types=(("Python Files", "*.py"),))],
|
||||
[sg.Text('Icon File'), sg.Input(key='-iconfile-', size=(45, 1)),
|
||||
sg.FileBrowse(file_types=(("Icon Files", "*.ico"),))],
|
||||
[sg.Frame('Output', font='Any 15', layout=[
|
||||
[sg.Output(size=(65, 15), font='Courier 10')]])],
|
||||
[sg.ReadFormButton('Make EXE', bind_return_key=True),
|
||||
sg.SimpleButton('Quit', button_color=('white', 'firebrick3')), ]]
|
||||
|
||||
window = sg.Window('PySimpleGUI EXE Maker',
|
||||
layout,
|
||||
auto_size_text=False,
|
||||
auto_size_buttons=False,
|
||||
default_element_size=(20,1,),
|
||||
default_element_size=(20, 1,),
|
||||
text_justification='right')
|
||||
|
||||
window.Layout(layout)
|
||||
|
||||
# ---===--- Loop taking in user input --- #
|
||||
while True:
|
||||
(button, values) = window.Read()
|
||||
if button in ('Quit', None):
|
||||
break # exit button clicked
|
||||
|
||||
source_file = values['_sourcefile_']
|
||||
icon_file = values['_iconfile_']
|
||||
event, values = window.read()
|
||||
if event in ('Exit', 'Quit', None):
|
||||
break
|
||||
|
||||
source_file = values['-sourcefile-']
|
||||
icon_file = values['-iconfile-']
|
||||
|
||||
icon_option = '-i "{}"'.format(icon_file) if icon_file else ''
|
||||
source_path, source_filename = os.path.split(source_file)
|
||||
workpath_option = '--workpath "{}"'.format(source_path)
|
||||
dispath_option = '--distpath "{}"'.format(source_path)
|
||||
specpath_option = '--specpath "{}"'.format(source_path)
|
||||
folder_to_remove = os.path.join(source_path,source_filename[:-3])
|
||||
file_to_remove = os.path.join(source_path, source_filename[:-3]+'.spec')
|
||||
command_line = 'pyinstaller -wF "{}" {} {} {} {}'.format(source_file, icon_option, workpath_option, dispath_option, specpath_option)
|
||||
folder_to_remove = os.path.join(source_path, source_filename[:-3])
|
||||
file_to_remove = os.path.join(
|
||||
source_path, source_filename[:-3]+'.spec')
|
||||
command_line = 'pyinstaller -wF "{}" {} {} {} {}'.format(
|
||||
source_file, icon_option, workpath_option, dispath_option, specpath_option)
|
||||
|
||||
if button == 'Make EXE':
|
||||
if event == 'Make EXE':
|
||||
try:
|
||||
print(command_line)
|
||||
print('Making EXE... this will take a while.. the program has NOT locked up...')
|
||||
window.Refresh()
|
||||
print(
|
||||
'Making EXE...the program has NOT locked up...')
|
||||
window.refresh()
|
||||
# print('Running command {}'.format(command_line))
|
||||
runCommand(command_line)
|
||||
shutil.rmtree(folder_to_remove)
|
||||
os.remove(file_to_remove)
|
||||
print('**** DONE ****')
|
||||
except:
|
||||
sg.PopupError('Something went wrong')
|
||||
sg.popup_error('Something went wrong')
|
||||
|
||||
|
||||
def runCommand(cmd, timeout=None):
|
||||
""" run shell command
|
||||
"""
|
||||
run shell command
|
||||
|
||||
@param cmd: command to execute
|
||||
@param timeout: timeout for command execution
|
||||
@param cmd: command to execute
|
||||
@param timeout: timeout for command execution
|
||||
|
||||
@return: (return code from command, command output)
|
||||
"""
|
||||
@return: (return code from command, command output)
|
||||
"""
|
||||
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
output = ''
|
||||
|
||||
out, err = p.communicate()
|
||||
p.wait(timeout)
|
||||
|
||||
return (out, err)
|
||||
|
||||
if __name__ == '__main__':
|
||||
Launcher()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue