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

Ho Yeung Lee jobmattcon at gmail.com
Thu Mar 16 01:40:17 EDT 2017


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()


On Thursday, March 16, 2017 at 1:16:41 PM UTC+8, Ho Yeung Lee wrote:
> martin at 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()
> 
> 
> On Thursday, March 16, 2017 at 12:40:16 PM UTC+8, Ho Yeung Lee wrote:
> > 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()



More information about the Python-list mailing list