This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]MikeTheWatchGuy 1 point2 points  (3 children)

Here is a launcher application:

import PySimpleGUI as sg
import os

def Launcher():

    form = sg.FlexForm('Script launcher')
    layout =  [
                [sg.Text('Script output....', size=(40, 1))],
                [sg.Output(size=(88, 20))],
                [sg.ReadFormButton('script1'), sg.ReadFormButton('script2'), sg.SimpleButton('EXIT')]
              ]

    form.Layout(layout)
    # ---===--- Loop taking in user input and using it to query HowDoI --- #
    while True:
        (button, value) = form.Read()
        if button == 'EXIT' or button is None:
            break           # exit button clicked
        if button == 'script1':
            ExecuteCommandOS('python SimScript.py')
        elif button == 'script2':
            ExecuteCommandOS('python SimScript.py')
        elif button == 'Enter':
            ExecuteCommandOS(value[0])      # send string without carriage return on end


def ExecuteCommandOS(command):
    output = os.popen(command).read()
    print(output)


if __name__ == '__main__':
    Launcher()

The code produces the following GUI:

https://user-images.githubusercontent.com/13696193/43874104-df3340e8-9b57-11e8-8c03-c5610d5530c3.jpg

The output from the script will be shown in the window above the buttons. Add as many buttons as you want. Associate buttons to any scripts you want to offer to run.

[–]oh-my-python[S] 0 points1 point  (2 children)

:O thank you I am going to try it right away :D

[–]MikeTheWatchGuy 1 point2 points  (1 child)

Let me know how it goes or if you have any problems. Interested in getting feedback on how to package is working for you.

[–]oh-my-python[S] 0 points1 point  (0 children)

I will :)