首页 > 解决方案 > 为什么我在 Tkinter 中收到“执行格式错误”消息

问题描述

我只想在 Raspberry PI 中运行来自 Tkinter 的 MP4 视频。如果我只是浏览到它所在的目录并单击它,则视频运行没有任何问题。它使用 VLC 播放视频。但是当我运行 Tkinter 程序并找到视频文件并运行它时,它给了我错误消息。

sh: 1: /home/Documents/Bobby/Pictures/myvideo.mp4: "Exec format error"

这是我的代码;

import tkinter as tk
# use ffmplay to play the videos with tkinter
import tkinter.ttk as ttk
import os

root = tk.Tk()

lb = tk.Listbox(root)
lb.pack()

def ffplay(event):
    if lb.curselection():
        file = lb.curselection()[0]
        os.system("/home/pi/Documents/Bobby/Pictures/myvideo.mp4")

for file in os.listdir('/home/pi/Documents/Bobby/Pictures/'):
    if file.endswith(".mp4"):
        lb.insert(0, file)Exec format errorExec format error

bstart = ttk.Button(root, text="Start movie")
bstart.pack()

bstart.bind("<ButtonPress-1>", ffplay)
root.mainloop()

标签: pythontkinterraspberry-pi

解决方案


推荐阅读