[GH-ISSUE #354] Failing to Display .html file after converting #294

Closed
opened 2026-02-26 12:21:06 +03:00 by kerem · 5 comments
Owner

Originally created by @mark-fein on GitHub (Jan 17, 2023).
Original GitHub issue: https://github.com/brentvollebregt/auto-py-to-exe/issues/354

Originally assigned to: @mark-fein on GitHub.

As in the title I have the following code in my .py file:

# Open Graph in Web Browser
fig.write_html("my_plot.html")
webbrowser.open("my_plot.html")

However, when I run the output .exe file, my splash screen where the user inputs data apepars, I am able to input data but nothing happens when "Run" is pressed.

image

Thoughts?

Is the "Run" button busted, or is it just failing to open the html file?

Here is code for Input Screen:

# DATA INPUT, DO NOT EDIT BELOW THIS LINE EXCEPT FOR INPUT MOD        
        
def open_file():  
    add_file = filedialog.askopenfilename()
    file_name.append(add_file) 
               
def run_app():
    global entry1, entry2, canvas, file1, file2, file_name
    root = tk.Tk()
    root.title("3D Heatmap Generator")
    
    file_name = []

    # Add widgets to the window

    label1 = tk.Label(root, text="Enter target etch depth (nm):")
    label1.grid(row=1, column=0)
    entry1 = tk.Entry(root)
    entry1.grid(row=2, column=0)
    label2 = tk.Label(root, text="Enter the number of measurement points:")
    label2.grid(row=3, column=0)
    entry2 = tk.Entry(root)
    entry2.grid(row=4, column=0)
    open_file1_button = tk.Button(root, text="Open Initial Measurement File (.xlsx only)", command=open_file)
    open_file1_button.grid(row=5, column=0)

    open_file2_button = tk.Button(root, text="Open Final Measurement File (.xlsx only)", command=open_file)
    open_file2_button.grid(row=6, column=0)

    button = tk.Button(root, text="Run Program", command=check_number)
    button.grid(row=7, column=0)
        
    w = 230
    h = 160
    ws = root.winfo_screenwidth()
    hs = root.winfo_screenheight()
    x = (ws/2) - (w/2)
    y = (hs/2) - (h/2)
    root.geometry('%dx%d+%d+%d' % (w, h, x, y))
    root.mainloop()
run_app()
Originally created by @mark-fein on GitHub (Jan 17, 2023). Original GitHub issue: https://github.com/brentvollebregt/auto-py-to-exe/issues/354 Originally assigned to: @mark-fein on GitHub. As in the title I have the following code in my .py file: ``` # Open Graph in Web Browser fig.write_html("my_plot.html") webbrowser.open("my_plot.html") ``` However, when I run the output .exe file, my splash screen where the user inputs data apepars, I am able to input data but nothing happens when "Run" is pressed. <img width="197" alt="image" src="https://user-images.githubusercontent.com/91111307/213023729-e13b209e-6304-40cc-a989-2c235555cdaf.png"> Thoughts? Is the "Run" button busted, or is it just failing to open the html file? Here is code for Input Screen: ``` # DATA INPUT, DO NOT EDIT BELOW THIS LINE EXCEPT FOR INPUT MOD def open_file(): add_file = filedialog.askopenfilename() file_name.append(add_file) def run_app(): global entry1, entry2, canvas, file1, file2, file_name root = tk.Tk() root.title("3D Heatmap Generator") file_name = [] # Add widgets to the window label1 = tk.Label(root, text="Enter target etch depth (nm):") label1.grid(row=1, column=0) entry1 = tk.Entry(root) entry1.grid(row=2, column=0) label2 = tk.Label(root, text="Enter the number of measurement points:") label2.grid(row=3, column=0) entry2 = tk.Entry(root) entry2.grid(row=4, column=0) open_file1_button = tk.Button(root, text="Open Initial Measurement File (.xlsx only)", command=open_file) open_file1_button.grid(row=5, column=0) open_file2_button = tk.Button(root, text="Open Final Measurement File (.xlsx only)", command=open_file) open_file2_button.grid(row=6, column=0) button = tk.Button(root, text="Run Program", command=check_number) button.grid(row=7, column=0) w = 230 h = 160 ws = root.winfo_screenwidth() hs = root.winfo_screenheight() x = (ws/2) - (w/2) y = (hs/2) - (h/2) root.geometry('%dx%d+%d+%d' % (w, h, x, y)) root.mainloop() run_app() ```
kerem 2026-02-26 12:21:06 +03:00
Author
Owner

@brentvollebregt commented on GitHub (Jan 18, 2023):

Have you followed the help post? What did you find when following the debugging steps?

You haven't said where this my_plot.html file comes from - maybe you forgot to add it to the additional files section? If this is the case, the debugging steps would have stated the file is missing and you would be able to validate it in one director mode.

<!-- gh-comment-id:1386488759 --> @brentvollebregt commented on GitHub (Jan 18, 2023): Have you followed the help post? What did you find when following the debugging steps? You haven't said where this `my_plot.html` file comes from - maybe you forgot to add it to the additional files section? If this is the case, the debugging steps would have stated the file is missing and you would be able to validate it in one director mode.
Author
Owner

@mark-fein commented on GitHub (Jan 18, 2023):

It is located within the same .py file as the original code above. When I run it as a .ipynb it works great, its only when its converted over to .exe that it fails to do anything.

See below for the entire code. Again it is a single file, and doesn't reference any other files.

import tkinter as tk
from tkinter import simpledialog
from tkinter import filedialog
from tkinter import messagebox
from tkinter.filedialog import askopenfilename
import pandas as pd
import numpy as np
import sys


def check_number():
    text1 = entry1.get()
    text2 = entry2.get()
    try:
        float(text1)
        float(text2)
    except ValueError:
        messagebox.showerror("Error", "Please enter a whole number")
    else:
  
        target_depth = int(entry1.get())
        num_meas_points = int(entry2.get())
        
        df = pd.read_excel(file_name[0], sheet_name=0)
        
        # Drop first two columns
        df.drop(df.columns[[0, 1]], axis=1, inplace=True)

        # Drop first set of empty rows
        df.dropna(how='all', axis=0, inplace=True)

        # Pull first row as column namesin dataframe and set them as column names
        df.columns = df.iloc[0].tolist()
        df = df[~df.index.isin(df.columns)]

        # Convert dataframe entries from strings to floats/NAs and then drop NAs
        df = df.apply(lambda x: pd.to_numeric(x, errors='coerce'))
        df.dropna(how='all', axis=0, inplace=True)

        # Reset the index
        df = df.reset_index(drop=True)

        # Set x and y
        x = 7  # every 7 rows (i.e. Min/Max/Avg Data)
        y = num_meas_points  # every N points

        # Iterate over the DataFrame in steps of y to remove average data points
        for i in range(y+1, len(df), y):
            # Delete every x rows
            df.drop(df.index[i-1:i-1+x], inplace=True) 

        # Only select needed data
        columns_to_keep = ["Thick1 (nm)", "X(mm)", "Y(mm)"]
        df = df[columns_to_keep]
    
        # # Reset index for final time
        # df = df.reset_index(drop=True)

        # Drop last few rows
        df.drop(df.tail(x).index, inplace = True)

        # Set before etch depth
        df_before = df
        
        # The same, but for second file
        df = pd.read_excel(file_name[1], sheet_name=0)

        # Drop first two columns
        df.drop(df.columns[[0, 1]], axis=1, inplace=True)

        # Drop first set of empty rows
        df.dropna(how='all', axis=0, inplace=True)

        # Pull first row as column namesin dataframe and set them as column names
        df.columns = df.iloc[0].tolist()
        df = df[~df.index.isin(df.columns)]

        # Convert dataframe entries from strings to floats/NAs and then drop NAs
        df = df.apply(lambda x: pd.to_numeric(x, errors='coerce'))
        df.dropna(how='all', axis=0, inplace=True)

        # Reset the index
        df = df.reset_index(drop=True)

        # Set x and y
        x = 7  # every 7 rows (i.e. Min/Max/Avg Data)
        y = num_meas_points  # every N points

        # Iterate over the DataFrame in steps of y to remove average data points
        for i in range(y+1, len(df), y):
            # Delete every x rows
            df.drop(df.index[i-1:i-1+x], inplace=True) 
    
        # Drop last averagingrows
        df.drop(df.columns[[1,2,3,4,5,6,7,8,9,10,13,14]], axis=1, inplace=True)
    
        # Reset index for final time
        df = df.reset_index(drop=True)

        # Drop last few rows
        df.drop(df.tail(x).index, inplace = True)

        # Set after etch depth
        df_after = df

        # Subtract off After from Before
        diff_df = df[['X(mm)','Y(mm)']]
        diff_df['Etch Depth (nm)'] = df_before[['Thick1 (nm)']] - df_after[['Thick1 (nm)']]

        # Rounding
        diff_df=diff_df.round(2)
        

        import plotly_express as px
        import plotly.graph_objects as go
        import numpy as np
        import webbrowser


        # 3D Heatmap

        x = diff_df["X(mm)"].values
        y = diff_df["Y(mm)"].values
        z = -diff_df["Etch Depth (nm)"].values

        # Create the 3D Heatmap
        fig = px.scatter_3d(
                            x=x[0:225], 
                            y=y[0:225], 
                            z=z[0:225], 
                            color=z[0:225], 
                            color_continuous_scale=[[0, 'red'], [0.5, 'green'], [1, 'red']]
                            )

        # Generate x, y, z coordinates for the disk
        r = 75
        x_disk = x
        y_disk = y
        z_disk = np.ones(len(z))*200*(-1)

        # Add the disk as a new trace to the existing scatter plot
        fig.add_trace(go.Scatter3d(x=x_disk, 
                                   y=y_disk, 
                                   z=z_disk,mode='markers', 
                                   marker=dict(size=10, 
                                               color='blue', 
                                               opacity=0.10),
                                   showlegend = False
                                  )
                     )

        fig.update_layout(scene = dict(
                            xaxis_title=diff_df.columns[0],
                            yaxis_title=diff_df.columns[1],
                            zaxis_title=diff_df.columns[2]),
                            margin=dict(r=20, b=10, l=10, t=10),
                            coloraxis_colorbar_title_text = diff_df.columns[2]    
                         )

        # Open Graph in Web Browser
        fig.write_html("my_plot.html")
        webbrowser.open("my_plot.html")


    

            
            
# DATA INPUT, DO NOT EDIT BELOW THIS LINE EXCEPT FOR INPUT MOD        
        
def open_file():  
    add_file = filedialog.askopenfilename()
    file_name.append(add_file) 
               
def run_app():
    global entry1, entry2, canvas, file1, file2, file_name
    root = tk.Tk()
    root.title("3D Heatmap Generator")
    
    file_name = []

    # Add widgets to the window
    
#     canvas = tk.Canvas(root, width=800, height=800)
#     canvas.grid(row=0, column=0)
#     canvas.create_rectangle(0, 0, 1000, 1000, fill="white")
    
    label1 = tk.Label(root, text="Enter target etch depth (nm):")
    label1.grid(row=1, column=0)
    entry1 = tk.Entry(root)
    entry1.grid(row=2, column=0)
    label2 = tk.Label(root, text="Enter the number of measurement points:")
    label2.grid(row=3, column=0)
    entry2 = tk.Entry(root)
    entry2.grid(row=4, column=0)
    open_file1_button = tk.Button(root, text="Open Initial Measurement File (.xlsx only)", command=open_file)
    open_file1_button.grid(row=5, column=0)

    open_file2_button = tk.Button(root, text="Open Final Measurement File (.xlsx only)", command=open_file)
    open_file2_button.grid(row=6, column=0)

    button = tk.Button(root, text="Run Program", command=check_number)
    button.grid(row=7, column=0)
        
    w = 230
    h = 160
    ws = root.winfo_screenwidth()
    hs = root.winfo_screenheight()
    x = (ws/2) - (w/2)
    y = (hs/2) - (h/2)
    root.geometry('%dx%d+%d+%d' % (w, h, x, y))
    root.mainloop()
run_app()
<!-- gh-comment-id:1386500142 --> @mark-fein commented on GitHub (Jan 18, 2023): It is located within the same .py file as the original code above. When I run it as a .ipynb it works great, its only when its converted over to .exe that it fails to do anything. See below for the entire code. Again it is a single file, and doesn't reference any other files. ``` import tkinter as tk from tkinter import simpledialog from tkinter import filedialog from tkinter import messagebox from tkinter.filedialog import askopenfilename import pandas as pd import numpy as np import sys def check_number(): text1 = entry1.get() text2 = entry2.get() try: float(text1) float(text2) except ValueError: messagebox.showerror("Error", "Please enter a whole number") else: target_depth = int(entry1.get()) num_meas_points = int(entry2.get()) df = pd.read_excel(file_name[0], sheet_name=0) # Drop first two columns df.drop(df.columns[[0, 1]], axis=1, inplace=True) # Drop first set of empty rows df.dropna(how='all', axis=0, inplace=True) # Pull first row as column namesin dataframe and set them as column names df.columns = df.iloc[0].tolist() df = df[~df.index.isin(df.columns)] # Convert dataframe entries from strings to floats/NAs and then drop NAs df = df.apply(lambda x: pd.to_numeric(x, errors='coerce')) df.dropna(how='all', axis=0, inplace=True) # Reset the index df = df.reset_index(drop=True) # Set x and y x = 7 # every 7 rows (i.e. Min/Max/Avg Data) y = num_meas_points # every N points # Iterate over the DataFrame in steps of y to remove average data points for i in range(y+1, len(df), y): # Delete every x rows df.drop(df.index[i-1:i-1+x], inplace=True) # Only select needed data columns_to_keep = ["Thick1 (nm)", "X(mm)", "Y(mm)"] df = df[columns_to_keep] # # Reset index for final time # df = df.reset_index(drop=True) # Drop last few rows df.drop(df.tail(x).index, inplace = True) # Set before etch depth df_before = df # The same, but for second file df = pd.read_excel(file_name[1], sheet_name=0) # Drop first two columns df.drop(df.columns[[0, 1]], axis=1, inplace=True) # Drop first set of empty rows df.dropna(how='all', axis=0, inplace=True) # Pull first row as column namesin dataframe and set them as column names df.columns = df.iloc[0].tolist() df = df[~df.index.isin(df.columns)] # Convert dataframe entries from strings to floats/NAs and then drop NAs df = df.apply(lambda x: pd.to_numeric(x, errors='coerce')) df.dropna(how='all', axis=0, inplace=True) # Reset the index df = df.reset_index(drop=True) # Set x and y x = 7 # every 7 rows (i.e. Min/Max/Avg Data) y = num_meas_points # every N points # Iterate over the DataFrame in steps of y to remove average data points for i in range(y+1, len(df), y): # Delete every x rows df.drop(df.index[i-1:i-1+x], inplace=True) # Drop last averagingrows df.drop(df.columns[[1,2,3,4,5,6,7,8,9,10,13,14]], axis=1, inplace=True) # Reset index for final time df = df.reset_index(drop=True) # Drop last few rows df.drop(df.tail(x).index, inplace = True) # Set after etch depth df_after = df # Subtract off After from Before diff_df = df[['X(mm)','Y(mm)']] diff_df['Etch Depth (nm)'] = df_before[['Thick1 (nm)']] - df_after[['Thick1 (nm)']] # Rounding diff_df=diff_df.round(2) import plotly_express as px import plotly.graph_objects as go import numpy as np import webbrowser # 3D Heatmap x = diff_df["X(mm)"].values y = diff_df["Y(mm)"].values z = -diff_df["Etch Depth (nm)"].values # Create the 3D Heatmap fig = px.scatter_3d( x=x[0:225], y=y[0:225], z=z[0:225], color=z[0:225], color_continuous_scale=[[0, 'red'], [0.5, 'green'], [1, 'red']] ) # Generate x, y, z coordinates for the disk r = 75 x_disk = x y_disk = y z_disk = np.ones(len(z))*200*(-1) # Add the disk as a new trace to the existing scatter plot fig.add_trace(go.Scatter3d(x=x_disk, y=y_disk, z=z_disk,mode='markers', marker=dict(size=10, color='blue', opacity=0.10), showlegend = False ) ) fig.update_layout(scene = dict( xaxis_title=diff_df.columns[0], yaxis_title=diff_df.columns[1], zaxis_title=diff_df.columns[2]), margin=dict(r=20, b=10, l=10, t=10), coloraxis_colorbar_title_text = diff_df.columns[2] ) # Open Graph in Web Browser fig.write_html("my_plot.html") webbrowser.open("my_plot.html") # DATA INPUT, DO NOT EDIT BELOW THIS LINE EXCEPT FOR INPUT MOD def open_file(): add_file = filedialog.askopenfilename() file_name.append(add_file) def run_app(): global entry1, entry2, canvas, file1, file2, file_name root = tk.Tk() root.title("3D Heatmap Generator") file_name = [] # Add widgets to the window # canvas = tk.Canvas(root, width=800, height=800) # canvas.grid(row=0, column=0) # canvas.create_rectangle(0, 0, 1000, 1000, fill="white") label1 = tk.Label(root, text="Enter target etch depth (nm):") label1.grid(row=1, column=0) entry1 = tk.Entry(root) entry1.grid(row=2, column=0) label2 = tk.Label(root, text="Enter the number of measurement points:") label2.grid(row=3, column=0) entry2 = tk.Entry(root) entry2.grid(row=4, column=0) open_file1_button = tk.Button(root, text="Open Initial Measurement File (.xlsx only)", command=open_file) open_file1_button.grid(row=5, column=0) open_file2_button = tk.Button(root, text="Open Final Measurement File (.xlsx only)", command=open_file) open_file2_button.grid(row=6, column=0) button = tk.Button(root, text="Run Program", command=check_number) button.grid(row=7, column=0) w = 230 h = 160 ws = root.winfo_screenwidth() hs = root.winfo_screenheight() x = (ws/2) - (w/2) y = (hs/2) - (h/2) root.geometry('%dx%d+%d+%d' % (w, h, x, y)) root.mainloop() run_app() ```
Author
Owner

@brentvollebregt commented on GitHub (Jan 18, 2023):

Have you followed the help post? What did you find when following the debugging steps?

What did you get when you read the supplied help material linked in the UI, at the end of every build and README?

<!-- gh-comment-id:1386512489 --> @brentvollebregt commented on GitHub (Jan 18, 2023): > Have you followed the help post? What did you find when following the debugging steps? What did you get when you read the supplied help material linked in the UI, at the end of every build and README?
Author
Owner

@github-actions[bot] commented on GitHub (Feb 20, 2023):

This issue is stale because it has been open for 60 days with no activity. Remove stale label or comment on this issue or it will be closed in 5 days.

<!-- gh-comment-id:1436164150 --> @github-actions[bot] commented on GitHub (Feb 20, 2023): This issue is stale because it has been open for 60 days with no activity. Remove stale label or comment on this issue or it will be closed in 5 days.
Author
Owner

@github-actions[bot] commented on GitHub (Feb 26, 2023):

Closing issue due to no activity in more than 60 days.

<!-- gh-comment-id:1445241128 --> @github-actions[bot] commented on GitHub (Feb 26, 2023): Closing issue due to no activity in more than 60 days.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/auto-py-to-exe#294
No description provided.