2

我正在使用它来创建一个 Windows 应用程序界面。我希望在界面中播放视频,并且不会弹出另一个播放视频的窗口。我发现了一个名为 Tkinter VideoPlayer 的库,它专门用于在标签上播放视频。但是,当我使用现有代码运行代码时,出现错误:

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

我知道“缩放”变量同时获得不同的值,这就是代码没有运行的原因。但是,我不确定如何解决这个问题。我将包括我的代码和 Github 存储库链接。Github 链接: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()
4

3 回答 3

1

您安装库的方式没有任何问题。

问题是您没有指定master=screen. TkinterVideo 采用的第一个参数是缩放的。所以需要master=screen在 TkinterVideo 中显式设置。例如:TkinterVideo(master=screen, scaled=True, pre_load=False)。顺便说一句,默认的缩放选项是 True 并且 pre_load 是 False 所以不需要显式设置它。

scaled选项会将视频大小调整为当前屏幕大小。如果将其设置为False,则可以使用 指定所需的帧大小videoplayer.set_size((300, 300))。注意:它需要元组作为参数

于 2022-01-10T08:33:03.693 回答
0

如果你现在还没有弄清楚,我有同样的错误,它只是通过在声明你的 TkinterVideo 时删除参数的名称来修复:

videoplayer = TkinterVideo(screen,True,False)

应该做的伎俩。

于 2021-12-26T12:49:51.150 回答
0

我必须为 tKinterVideoPlayer 运行 setup.py。但是,您确实需要 "scaled=" 和 "pre_load="

于 2022-01-07T18:19:23.237 回答