1

I am using it to create a windows app interface. I would like a video to play in the interface and not have another window pop up that plays the video. I have discovered a library called Tkinter VideoPlayer which is specifically used to play a video on a label. However, when I run the code with the existing code I have, I get the error:

TypeError: __init__() got multiple values for argument 'scaled'" .

I understand that the "scaled" variable is getting different values at the same time which is the reason why the code is not running. However, I am not sure how to fix this. I will include my code and the Github repository link. Github link: https://github.com/PaulleDemon/tkVideoPlayer/blob/master/tkVideoPlayer/tkvideoplayer.py

import tkinter as tk
from tkVideoPlayer import TkinterVideo


HEIGHT = 700
WIDTH = 800



root = tk.Tk()

#Canvas
canvas = tk.Canvas(root, height = HEIGHT, width=WIDTH)
canvas.pack()

#Background Picture
background_img = tk.PhotoImage(file = "GundamNarrative2.png")
background_label = tk.Label(root, image=background_img)
background_label.place(relwidth=1, relheight=1)

#Background
background = tk.Frame(root, bg = "blue")
background.place(relx=.5, rely=.1, relwidth=0.75, relheight=0.1, anchor="n")

# Buttons
record_button = tk.Button(background, text = "Record", bg = "green")
record_button.place(relx = 0, rely = .5, relwidth = 0.15, relheight = .5)

skeleton_button = tk.Button(background, text = "Skeleton", bg = "red")
skeleton_button.place(relx = .4, rely = .5, relwidth = 0.15, relheight = .5)

frame_button = tk.Button(background, text = "Frame", bg = "yellow")
frame_button.place(relx = .85, rely = .5, relwidth = 0.15, relheight = .5)

#Label
video_label = tk.Label(background, text = "Enter video name below")
video_label.place(relx = 0.4, rely=0, relwidth=.25, relheight=.15)

#Entry Area
entry = tk.Entry(background, bg = 'gray')
entry.place(relx = 0.4, rely=.15, relwidth=.25, relheight=.35)

#Bottom Frame
bottom_frame = tk.Frame(root, bg = "blue", bd=10)
bottom_frame.place(relx = .5, rely=0.25, relwidth=.75, relheight=.65, anchor = "n")

#Screen
screen = tk.Label(bottom_frame, text = "I want video to play here", bg = "gray")
screen.place(relx=0, rely=0, relwidth=1, relheight=1)

#Error in line below
videoplayer = TkinterVideo(screen, scaled=True, pre_load=False)
videoplayer.load("C:\\Users\\jcoli\\PycharmProjects\\SwimCodeProject\\PoseVideos\\Jordan.mov")
videoplayer.place(relx=0, rely=0, relwidth=1, relheight=1)

videoplayer.play()


root.mainloop()
Art
  • 2,836
  • 4
  • 17
  • 34
  • The problem is that you didn't specify `master=screen`. The first parameter the TkinterVideo takes is scaled. So you need to explicitly set `master=screen` in TkinterVideo. Eg: `TkinterVideo(master=screen, scaled=True, pre_load=False)`. Btw default scaled option is True and the pre_load is False so there isn't a need to set it explicitly. – Art Jan 10 '22 at 08:23

3 Answers3

0

In case you havent figured it out by now, I had the same error, it got fixed just by removing the name of the arguments when declaring your TkinterVideo :

videoplayer = TkinterVideo(screen,True,False)

should do the trick.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Jammin
  • 1
  • 1
  • I unfortunately did not get the issue to solve. I have added the error message in the initial question. Maybe there is something wrong with the way I installed the TkinterVideo library. I was unable to "pip install" it to PyCharm. Therefore, I just copied and pasted the library code into a new file. Would that be the problem and if yes, how would I reinstall it the proper way? –  Dec 27 '21 at 14:08
0

I had to run setup.py for tKinterVideoPlayer. However, you DO NEED "scaled=" and "pre_load="

0

There isn't any problem with the way you installed the library.

The problem is that you didn't specify master=screen. The first parameter the TkinterVideo takes is scaled. So you need to explicitly set master=screen in TkinterVideo. Eg: TkinterVideo(master=screen, scaled=True, pre_load=False). Btw, the default scaled option is True and the pre_load is False so there isn't a need to set it explicitly.

The scaled option will resize the video to the current screen size. If you set this to False you can specify the desired frame size using videoplayer.set_size((300, 300)). Note: it takes tuple as an argument

Art
  • 2,836
  • 4
  • 17
  • 34