macos – Open File Dialogue does not close after selection (Python 3.13)


I m running 12.7 on an iMac and using Python 3.13.

I have a 3D graph plotting script that at the moment I open using Python Launcher3. It work fine and quickly, but the window for choosing and opening the needed .xlsx* data file doesn’t close after a file is selected, and it cannot be closed. When the file is selected by hitting the ‘open’ button a small empty window ‘tk’ opens. The shell and editor windows also open (I don’t need either),

*spreadsheet is originally .osd and saved as ‘xlsx which was just easier to code

An image of the graph appears with data points plotted which I can rotate, save, etc. If I save the image, all windows remain open. If I close the image, the tk window and the file select window also close, and in the editor window show Saving session… …[Process competed]. If I close the tk window before closing graph image Python crashes. The shell and editor must be manually closed.

Here is the code from the script for choosing a file:

import  tkinter as tk
from tkinter import filedialog

root = tk.Tk()
root.withdraw()

file_path=filedialog.askopenfilename()
print(file_path)

df = pd.read_excel(file_path)
print(df.head)
print(df.columns)

I have tried adding the following before and after several lines, but it does not help.

root.destroy()

but no change

I could just live with it, but I am hoping it is one or two lines of code to correct this.



Source link

Related Posts

About The Author

Add Comment