Daily Tips - Double-click to open Dash 🤝

Hi there,

“I don’t know Python, can you give me a file and let me open it, as is the way I open an Excel worksheet, to view your report?”

Here you are.
dash71

You know, there are always sometimes. :man_shrugging:

Let’s make an offline file that looks like it can be opened at any time.

from dash import Dash
from flaskwebgui import FlaskUI

app = Dash(__name__)

server = app.server

if __name__ == "__main__":
    #app.run_server(debug=True)
    FlaskUI(server).run()

By changing these lines, we’re going to have a GUI window. This will be a lot much like a local program.

Then let’s hide the code to create the illusion of double-clicking to open.

mamba create -n packing --file .\requirements.txt

We need to create a virtual environment and install only the packages you need. Then we use pyinstaller to package your project.

pyinstaller.exe -F -w --add-data ".\assets\*;.\assets\"  --hidden-import sklearn.utils._typedefs  -i .\excel.ico --clean --add-binary "C:\ProgramData\mambaforge\pkgs\dash-daq-0.5.0-pyh9f0ad1d_1\site-packages\dash_daq\*.json;dash_daq" --add-binary ......   .\app.py

The -F parameter is used to tell pyinstaller that you want a bundled single-file executable.
The -w means no console window on Windows.
The delimiter is ; on Windows.
Ignore those following --add-binarys, you don’t necessarily need them.

Hope this helps you. XD

Keywords: Pyinstaller, GUI, FlaskUI

4 Likes