I have created two modules in python. One of the module is for creating GUI using Tkinter and second one is for capturing and storing images.When I called opencv module in Tkinter module,it runs opencv module first and after releasing camera,it was running Tkinter module.So I used subprocess.Popen(). Now I want output of subprocess into Tkinter module. The code for creating GUI using Tkinter is as follows.
import sys
from Tkinter import *
import Tkinter
import subprocess
def capcam():
command="python2 imacap.py"
subprocess.Popen(command,shell=True)
root=Tk()
add=Frame(root)
add.grid()
root.title("Test")
capcam()
button_height=11
button_width=29
button_ipadx=2
button_ipady=2
text_box = Entry(add,justify=RIGHT,width=100, font=100)
text_box.grid(row = 0, column = 1,columnspan = 5)
text_box.insert(0, "0")
bttn_3 = Button(add, height= button_height ,width= button_width,text = "3")
bttn_3.grid(row = 3, column = 2, padx=button_ipadx, pady=button_ipady)
Following is the code of child process.
import cv2.cv as cv
capture = cv.CaptureFromCAM(0)
num = 0
while True:
img = cv.QueryFrame(capture)
cv.SaveImage('pic'+str(num)+'.jpg', img)
if num == 500:
del(capture)
break
if cv.WaitKey(10) == 27:
break
num += 1
I want the value of num variable at runtime in mainprocess and want to pass it to entry without terminating child process.