Python Forum
Subprocess window won't open on Mac
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Subprocess window won't open on Mac
So I've been working on a rental form program for my work. Long story short I am using tkinter gui and I've set up a subprocess to open the specific rental form program from the main menu. Each .py file opens perfectly fine individually but wont open when its called from the sub-process.

I get an error in terminal that says ImportError: No module named tkinter.

For the record, all of my .py files that are part of this have tkinter imported.

Any help is appreciated
This simple example works for me, but I am using Windows instead of a mac.
import tkinter as tk
import subprocess

proc = None

def launch_proc():
    global proc
    proc = subprocess.Popen(['python', ''])

def kill_proc():
    global proc
    if proc is not None:
        proc = None

root = tk.Tk()
tk.Button(root, text='Launch', command=launch_proc).pack()
tk.Button(root, text='Kill', command=kill_proc).pack()
import tkinter as tk

root = tk.Tk()
tk.Label(root, text='2nd window').pack()
Just because this works for me doesn't mean I endorse writing programs like this. Were I writing a project with multiple forms, I would probably use a notebook and make a page for each form. One application, multiple views, and a very clean way to go from one form to another.

Possibly Related Threads…
Thread Author Replies Views Last Post
  Now if window is open or not delcencen 5 380 Mar-25-2023, 07:26 PM
Last Post: deanhystad
  [PyQt] Hover over highlighted text and open popup window DrakeSoft 2 420 Oct-29-2022, 04:30 PM
Last Post: DrakeSoft
  [Tkinter] Open tkinter colorchooser at toplevel (so I can select/focus on either window) tabreturn 4 786 Jul-06-2022, 01:03 PM
Last Post: deanhystad
  Second Window can't open due to iExit function Jionni 4 1,858 Feb-29-2020, 06:06 PM
Last Post: Jionni
  tkinter window and turtle window error 1885 3 5,442 Nov-02-2019, 12:18 PM
Last Post: 1885
  update a variable in parent window after closing its toplevel window gray 5 7,737 Mar-20-2017, 10:35 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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