I'm currently developing a Windows application that requires the use of an .exe file I've created (called kill_game.exe
in the below example). This .exe file accepts serialized objects as arguments. I call this .exe file using subprocess.Popen
. When I do so, an exact copy of my current window opens and my .exe file won't run until I close the 2nd window myself. I'm completely stumped as to why it happens. I'd like the .exe file to run without the 2nd GUI opening itself. I tried to switch to multiprocessing
as it exists in this example on SO, but that didn't work either.
Below, I'll post a simplified version (my original version is 300+ lines) of my code that illustrates the GUI and the function that is used to open the .exe file. I'll also post pictures of what happens when I press the button.
from tkinter import *
from tkinter import Tk
import subprocess
root = Tk()
sizex = sizey = 500
posx = posy = 100
root.wm_geometry("%dx%d+%d+%d" % (sizex, sizey, posx, posy))
myframe = Frame(root, relief=GROOVE, width=500, height=500, bd=1)
myframe.place(x=0, y=0)
canvas = Canvas(myframe)
frame = Frame(canvas)
canvas.pack(side="left")
canvas.create_window((0, 0), window=frame, anchor='nw')
button = Button(frame, text="Hello World")
button.grid(row=0, column=2)
games_to_stop = []
button.bind("<Button>",
lambda event, game_list=games_to_stop: some_function(game_list))
def some_function(game_list):
#This function is the function of interest, which is bound to my "Hello
#World" Button
child_script = r"C:\Users\Willy\AddictKiller\dist\kill_game.exe"
subprocess.Popen([child_script, game_list])
root.mainloop()
This is the GUI before the button is pressed:
This is the GUI and the 2nd GUI (which for some reason looks the the GUI of my non-simplified code) after the button is pressed: