Making a Python script accessible

Hey !

I wrote some scripts to automatize repetitive tasks for my colleagues using python.

Today I execute it for them and send the output through email.

I want to "give" them the script so they can use it whenever they want. I was thinking on making a GUI with tkinter, or making it available through a web app maybe ?

They are totally not tech savvy so teaching them command line will take too much time.

What would be your advice ?

Thanks 🐍!

16 comments · 56% upvoted · other discussions

comments

koning_willy

Where i work i create gui with pyqt en then package them with pyinstaller into a nice exe.

I make my team store the exe's on their desktops. They do not even need to know how to run python scripts or even install the interpretor...

Etheo

Agreed - compiling into a stand alone exe seems to be the most sensible solution in this use case. Getting a python environment on their machines or hosting a web app is more troublesome.

oh-my-python [OP]

Yeah, I think too. My idea was for them to input a csv, and it would use the info in the file and output either other csv files or html files.

So the process of uploading data seems quite troublesome.

oh-my-python [OP]

Ow, I will try this.

Does it work well when including libraries (sql, pandas, etc ...) ? Any precautions to take ?

Thanks !

koning_willy

Are you referring to pyinstaller? Not familiar with sql or pandas library. Opencv, pillow, Matplotlib and sqlite however seemed to work just fine :)

ominous_anonymous

Does it work well when including libraries (sql, pandas, etc ...) ?

Yes, there's a --onefile flag to give pyinstaller to indicate you want everything packaged up.

Keep in mind this makes the final executable a lot larger.

oh-my-python [OP]

Thanks !

firedrow

If you're saavy, or your IT team will work with you, a WebApp is always appreciated by non-technical people. I like using my Caddy Web Server with the Python scripts done as CGI scripts. Then you can make a web form, have them input the data, submit it to the script as CGI, then you output whatever way you want.

koning_willy

Maybe in small companies, in larger companies however there are lots of rules and policies to follow. You cant just get a server set up on your demand and you dont just set up a rouge server.

If i would do that kind of shit i would be fired as soon as the server gets identified by the ITdept.

A pineapple almost cost me a job already, should not have named its ssid anonymous

oh-my-python [OP]

The thing is it is a little association (we are 8) and we don't have proper IT support :p.

I think I'll ditch the WebApp as it will take too much time compared to the creation a exe or dmg script.

Saphyel

a webapp is x-platform so you will avoid a lot of issues with mac/windows versions

MikeTheWatchGuy

Can you install Python on their systems? If so...

Toss a GUI onto the front-end of your utilities and then let users double-click the .py file. It'll launch straight into a GUI.

Try PySimpleGUI to get up and running in a few minutes to see what it feels like to use your programs with a GUI. It's worth the 5 minutes it'll take.

pip install PySimpleGUI

Docs

http://pysimplegui.readthedocs.io/

GitHub

https://github.com/MikeTheWatchGuy/PySimpleGUI

MikeTheWatchGuy

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 [OP]

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

MikeTheWatchGuy

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 [OP]

I will :)