-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoy_gui1.py
143 lines (99 loc) · 3.06 KB
/
toy_gui1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# from tkinter import *
# canvas_width = 300
# canvas_height =300
# master = Tk()
# canvas = Canvas(master,
# width=canvas_width,
# height=canvas_height)
# canvas.pack()
# mainloop()
# from tkinter import filedialog
# from tkinter import *
# import tkinter as tk
# def write_slogan():
# print("Tkinter is easy to use!")
# video = tkinter.Frame(root, bg='#000000')
# video.pack(side=tkinter.BOTTOM,anchor=tkinter.S,expand=tkinter.YES,fill=tkinter.BOTH)
# root = tk.Tk()
# frame = tk.Frame(root)
# frame.pack()
# canvas_width = 300
# canvas_height =300
# canvas = Canvas(root,
# width=canvas_width,
# height=canvas_height)
# canvas.pack()
# button = tk.Button(frame,
# text="QUIT",
# fg="red",
# command=quit)
# button.pack(side=tk.LEFT)
# slogan = tk.Button(frame,
# text="Hello",
# command=write_slogan)
# slogan.pack(side=tk.LEFT)
# root.mainloop()
# from tkinter import *
# canvas_width = 300
# canvas_height =300
# master = Tk()
# canvas = Canvas(master,
# width=canvas_width,
# height=canvas_height)
# canvas.pack()
# mainloop()
# from tkinter import filedialog
# from tkinter import *
# import tkinter as tk
# def write_slogan():
# print("Tkinter is easy to use!")
# video = tkinter.Frame(root, bg='#000000')
# video.pack(side=tkinter.BOTTOM,anchor=tkinter.S,expand=tkinter.YES,fill=tkinter.BOTH)
# root = tk.Tk()
# frame = tk.Frame(root)
# frame.pack()
# canvas_width = 300
# canvas_height =300
# canvas = Canvas(root,
# width=canvas_width,
# height=canvas_height)
# canvas.pack()
# button = tk.Button(frame,
# text="QUIT",
# fg="red",
# command=quit)
# button.pack(side=tk.LEFT)
# slogan = tk.Button(frame,
# text="Hello",
# command=write_slogan)
# slogan.pack(side=tk.LEFT)
# root.mainloop()
import os
import sys
import tkinter
import gi
gi.require_version('Gst', '1.0')
from gi.repository import Gst, GObject
def on_sync_message(bus, message, window_id):
if not message.structure is None:
if message.structure.get_name() == 'prepare-xwindow-id':
image_sink = message.src
image_sink.set_property('force-aspect-ratio', True)
image_sink.set_xwindow_id(window_id)
GObject.threads_init()
Gst.init(None)
window = tkinter.Tk()
window.geometry('500x400')
video = tkinter.Frame(window, bg='#000000')
video.pack(side=tkinter.BOTTOM,anchor=tkinter.S,expand=tkinter.YES,fill=tkinter.BOTH)
window_id = video.winfo_id()
player = Gst.ElementFactory.make('playbin', 'player')
print(player)
# player.set_property('video-sink', None)
player.set_property('uri', '/home/yaswanth/casuality_of_eeg/jhbuild/v.mp4')
player.set_state(Gst.State.PLAYING)
bus = player.get_bus()
bus.add_signal_watch()
bus.enable_sync_message_emission()
bus.connect('sync-message::element', on_sync_message, window_id)
window.mainloop()