0
from Tkinter import *
from PIL import Image, ImageTk
import os

class App:
    def __init__(self,master):
        master.minsize(width=666, height=666)
        master["bg"] = "black"

        self.button = Button(text="Camera1",command=self.playvid)
        self.button.pack(side= "top")
        self.img = ImageTk.PhotoImage(Image.open("car.png"))

        self.panel = Label(master, image=self.img)
        self.panel.pack(side = "bottom", fill = "both", expand = "yes") 

    def playvid(self):
        os.system("gst-launch-1.0 videotestsrc ! autovideosink")


root = Tk()

app = App(root)

root.mainloop()
root.destroy()

This is my code. If I press the s key, I want to stop the os.system process that creates the gstreamer window, i.e. if I press s then it should be equivalent to ctrl + c.

Also is it possible to play the video in tkinter itself?

nbro
  • 15,395
  • 32
  • 113
  • 196
Ajayv
  • 374
  • 2
  • 13
  • This post may help: http://stackoverflow.com/q/2940858/3924118 – nbro Mar 14 '17 at 13:14
  • You need to use `subprocess.Popen` then. There is plenty of questions about it on SO: http://stackoverflow.com/questions/4084322/killing-a-process-created-with-pythons-subprocess-popen/4084373#4084373 – myaut Mar 14 '17 at 13:17
  • In order to render video inside Tkinter, follow this link: http://stackoverflow.com/questions/4937955/video-output-in-tkinter-from-gstreamer – Ahresse Mar 16 '17 at 18:11

0 Answers0