Python Forum
Launch pdf and close on delete window event
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Launch pdf and close on delete window event
#1
Hello I'm currently working on a GUI tool in python that launches PDF files from an SQL server. Right now I write the binary to a file and then launch it using subprocess Popen, I track the file name and store the actual subprocess object in a list. When the WM_DELETE_WINDOW event is called I iterate over the child processes killing them and then use os.remove to delete the files.

Here is my code. I can launch the PDF files fine but I can't get the files to close, I receive two errors (ProcessLookupError, psutil.NoSuchProcess: psutil.NoSuchProcess process no longer exists). My file also won't delete as the process is still in use.

 #destroy window and clean up after self
        self.window.destroy()
        #start by killing any processes
        for process in self.processes:
            for child in psutil.Process(process.pid).children():
                child.kill()
            process.kill()
        for file in self.saved_files:
            os.remove(file)
Any help is appreciated thanks.
Reply


Messages In This Thread
Launch pdf and close on delete window event - by ashtona - Mar-21-2018, 12:50 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Interaction between Matplotlib window, Python prompt and TKinter window NorbertMoussy 3 656 Mar-17-2024, 09:37 AM
Last Post: deanhystad
  [PyQt] command require close window Krissstian 14 3,166 Nov-19-2022, 04:18 PM
Last Post: Krissstian
  [Tkinter] Mouse click event not working on multiple tkinter window evrydaywannabe 2 3,815 Dec-16-2019, 04:47 AM
Last Post: woooee
  tkinter window and turtle window error 1885 3 6,807 Nov-02-2019, 12:18 PM
Last Post: 1885
  update a variable in parent window after closing its toplevel window gray 5 9,194 Mar-20-2017, 10:35 PM
Last Post: Larz60+
  pygtk2, how to disconnect all callback of widget or window event ? harun2525 1 3,356 Feb-19-2017, 11:44 PM
Last Post: Larz60+
  [Tkinter] I have a Toplevel button in tkinker that I want to close the window and then perform Bloodypizza17 2 7,854 Jan-06-2017, 07:18 PM
Last Post: Bloodypizza17
  launch .PY program Help iw2fo 22 20,334 Oct-18-2016, 09:13 PM
Last Post: Barrowman

Forum Jump:

User Panel Messages

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