Python Forum
Excel isnt working properly after python function is started
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Excel isnt working properly after python function is started
#2
When excel executes a Python script, it waits for the script to complete. Your script doesn't complete until the window is closed. This blocks excel from running. There are multiple ways to solve this problem. but the easiest might be to run the window script as a subprocess.

This is my window file (window.py)
import tkinter as tk

root = tk.Tk()
tk.Button(root, text="Close", command=root.destroy).pack(padx=100, pady=100)
root.mainloop()
I can do that by running the window as a subprocess.

This is a python script that runs window.py as a subprocess.
import subprocess

subprocess.Popen(["python", "window.py"])
print("I am done")
Your spreadsheet calls the launch script. The lauch script starts a process to run the window.py script. Because the launch script uses Popen withou a wait(), it doesn't wait for the window to close, and doesn't block the spreadsheet.
You'll need to use absolute paths for python.exe and window.py.
IchNar likes this post
Reply


Messages In This Thread
RE: Excel isnt working properly after python function is started - by deanhystad - May-01-2024, 05:20 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  File Handling not working properly TheLummen 8 1,182 Feb-17-2024, 07:47 PM
Last Post: TheLummen
Shocked kindly support with this dropna function not working gheevarpaulosejobs 2 841 Jul-24-2023, 03:41 PM
Last Post: deanhystad
  How do I properly implement restarting a multithreaded python application? MrFentazis 1 770 Jul-17-2023, 09:10 PM
Last Post: JamesSmith
  Cannot get started standenman 4 1,391 Feb-22-2023, 05:25 PM
Last Post: standenman
  Working with Excel and Word, Several Questions Regarding Find and Replace Brandon_Pickert 4 1,819 Feb-11-2023, 03:59 PM
Last Post: Brandon_Pickert
  How to properly format rows and columns in excel data from parsed .txt blocks jh67 7 2,179 Dec-12-2022, 08:22 PM
Last Post: jh67
  [Solved]Help Displaying Emails properly via Python Extra 5 1,367 Sep-28-2022, 09:28 PM
Last Post: deanhystad
Exclamation Function Not Working Alivegamer 7 2,067 Jul-19-2022, 01:03 PM
Last Post: deanhystad
  try function working on PC but not raspberry pi AnotherSam 1 1,660 Oct-11-2021, 04:51 AM
Last Post: bowlofred
  Working with excel files arsouzaesilva 6 3,393 Sep-17-2021, 06:52 PM
Last Post: arsouzaesilva

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020