Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to embed non-tkinter VLC player into grid of tkinter with python?

935 views
Skip to first unread message

Ho Yeung Lee

unread,
Mar 16, 2017, 12:40:16 AM3/16/17
to
we have many TV that would like to be monitored,

how to embed non-tkinter VLC player into grid of tkinter with python?

below code can embeded xterm but not for VLC player


import vlc
from Tkinter import *
import os

root = Tk()
for r in range(2):
for c in range(1):
termf = Frame(root, height=100, width=200)
termf.pack(fill=BOTH, expand=YES)
wid = termf.winfo_id()
termf.grid(row=r,column=c)
p=vlc.MediaPlayer('file:///home/martin/Downloads/autoweb.mp4')
p.get_tk_widget().grid(row=r,column=c)
p.play()
#os.system('xterm -into %d -geometry 40x20 -sb &' % wid)
os.system('vlc --no-fullscreen "file:///home/martin/Downloads/autoweb.mp4" -into %d -geometry 100x200 -sb &' % wid)

root.mainloop()

Ho Yeung Lee

unread,
Mar 16, 2017, 1:16:41 AM3/16/17
to
martin@ubuntu:~/Downloads/python-vlc/examples$ xdg-screensaver: Window 0x09000000 does not exist

error when run after inherit a frame which put in a grid

import vlc
from Tkinter import *
import os

import Tkinter as tk

class SampleApp(tk.Frame):
def __init__(self, parent, title=None):
#def __init__(self, *args, **kwargs):
#tk.Tk.__init__(self, *args, **kwargs)
tk.Frame.__init__(self, parent)
self.parent = parent
self.parent.title("video")
p=vlc.MediaPlayer('file:///home/martin/Downloads/autoweb.mp4')
p.play()
self.register()
#self.grid(row=1,column=1)

root = Tk()
for r in range(5):
for c in range(5):
termf = Frame(root, height=200, width=300)
termf.pack(fill=BOTH, expand=YES)
wid = termf.winfo_id()
#player = Player()
SampleApp(root, title="tkinter vlc").grid(row=r,column=c)
#os.system('xterm -into %d -geometry 40x20 -sb &' % wid)
#os.system('vlc --no-fullscreen "file:///home/martin/Downloads/autoweb.mp4" -into %d -geometry 100x200 -sb &' % wid)

root.mainloop()

Ho Yeung Lee

unread,
Mar 16, 2017, 1:40:29 AM3/16/17
to
after several trial, still can not put the player into grid

import vlc
from Tkinter import *
import os
import sys
import ttk

import Tkinter as tk

class SampleApp(tk.Frame):
def __init__(self, parent, title=None):
#def __init__(self, *args, **kwargs):
#tk.Tk.__init__(self, *args, **kwargs)
tk.Frame.__init__(self, parent)
self.parent = parent
self.parent.title("video")
self.player = None
self.Instance = vlc.Instance('--no-audio')
self.player = self.Instance.media_player_new()
#self.player.set_xwindow(ttk.Frame(self.parent).winfo_id())
p=self.Instance.media_player_new()
m=self.Instance.media_new('file:///home/martin/Downloads/autoweb.mp4')
p.set_media(m)
p.play()
#self.videopanel =
#p=vlc.MediaPlayer('file:///home/martin/Downloads/autoweb.mp4')
#p.play()
self.register(self, parent)
#self.player.grid(row=1,column=1)

#def GetHandle(self):
#return self.videopanel.winfo_id()

root = Tk()
for r in range(2):
for c in range(1):
termf = Frame(root, height=200, width=300)
termf.pack(fill=BOTH, expand=YES)
wid = termf.winfo_id()
#player = Player()
SampleApp(root, title="tkinter vlc").grid(row=r,column=c)
#os.system('xterm -into %d -geometry 40x20 -sb &' % wid)
#os.system('vlc --no-fullscreen "file:///home/martin/Downloads/autoweb.mp4" -into %d -geometry 100x200 -sb &' % wid)

root.mainloop()


Christian Gollwitzer

unread,
Mar 16, 2017, 3:56:41 AM3/16/17
to
Am 16.03.17 um 05:40 schrieb Ho Yeung Lee:
Two questions:
1) Does VLC support the -into option? I know that mplayer has such an
option, but it is called -wid, for instance

2) Maybe the window needs to be mapped before? If so, insert a
root.update() after the grid and before you try to embed.

3) It seems you try to instantiate VLC through two different mechanisms,
via the python package vlc and via an external call to os.system.

Christian

akashs...@gmail.com

unread,
Mar 16, 2019, 6:24:58 AM3/16/19
to
how to add video within tkinter frame.I am trying to add multiple videos inside the frame.
0 new messages