3.8 C
New York
Saturday, November 23, 2024

macos: Open File dialog doesn’t shut after choice (Python 3.13)


I am operating 12.7 on an iMac and utilizing Python 3.13.

I’ve a 3D graphics plotting script that I at the moment open utilizing Python Launcher3. It really works nicely and rapidly, however the window for selecting and opening the mandatory .xlsx* knowledge file doesn’t shut after deciding on a file and can’t be closed. When the file is chosen by urgent the “open” button, a small empty “tk” window opens. The shell and editor home windows additionally open (I do not want them both),

*The spreadsheet was initially .osd and saved as ‘xlsx, which was simpler to code

A picture of the chart seems with knowledge factors plotted that I can rotate, save, and many others. If I save the picture, all home windows stay open. If I shut the picture, the tk window and the file choice window additionally shut, and the editor window reveals Saving session… …(Course of accomplished). If I shut the tk window earlier than closing the graph picture, Python crashes. The shell and editor have to be closed manually.

Right here is the script code to decide on 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 attempted including the next earlier than and after a number of traces however it would not assist.

root.destroy()

however there aren’t any modifications

I may reside with it, however I hope it is a line or two of code to repair it.

Related Articles

Latest Articles