

为mpv写一个简单的图形界面
source link: http://wwj718.github.io/post/%E5%B7%A5%E5%85%B7/mpv_gui/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

几个月前给朋友推荐过mpv,朋友非技术人员,而mpv只提供命令行工具,没有图形界面,周末下午逛github看到Gooey,觉得简单有趣,决定用它给mpv写一个简单的图形界面
需求很简单,通过点击桌面图标,之后选择电影文件,就能播放,而不需要使用图形界面,这应该是大多非技术用户习惯的操作。
mpv
mac下常见播放器有QuickTime,MplayerX,VLC。我之前用MplayerX居多,mpv 是 Mplayer 和 Mplayer2 项目的分支,目前活跃的开发者都转向开发 mpv。mpv基本可以满足一般用户的需要
mac下不同播放器的比较参考这里
Gooey
Turn (almost) any Python command line program into a full GUI application with one line
Gooey能轻易地把python命令行工具变为GUI应用,通过极少的代码
brew tap mpv-player/mpv
brew install mpv
which mpv # /usr/local/bin/mpv
使用:mpv /your/folder/yourfile.mp4
mpv在mac目前没有图形界面
Gooey
pip install Gooey //需要在sudo pip下安装,wxpython要求比较多,virtuanenv下比较麻烦,具体可以参考wxPythonVirtualenvOnMac
依赖wxpython
,安装wxpython
brew install wxpython
cd /Library/Python/2.7/site-packages
ln -s /usr/local/Cellar/wxpython/3.0.2.0/lib/python2.7/site-packages/wx-3.0-osx_cocoa/wx/ wx
cat mpv_gui.py
#!/usr/bin/env python
# encoding: utf-8
#import argparse
from gooey import Gooey, GooeyParser
import subprocess
import sys
def handle(args):
filename = args.filename
# 播放,调用系统服务(mpv)
mpv = "/usr/local/bin/mpv"
# todo:变为独立进程
subprocess.Popen([mpv,filename])
@Gooey(language="chinese")
def main():
parser = GooeyParser(description=u'mpv_gui')
parser.add_argument('filename', help=u"请选择电影文件", widget='FileChooser')
args = parser.parse_args()
handle(args)
if __name__ == '__main__':
main()
mv mpv_gui.py mpv_gui
chmod +x mpv_gui
之后点击mpv_gui文件即可选择播放电影
如果你想把这个工具打包成无依赖的系统软件,可以试试pyinstaller
Gooey安装不方便,文件选择用tkinter的tkFileDialog就好了
from Tkinter import Tk
from tkFileDialog import askopenfilename
Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
filename = askopenfilename() # show an "Open" dialog box and return the path to the selected file , 在命令行下层?
print(filename)
后来发现可以直接安装mpv.app,之后绑定格式和播放工具 (参考 全能高效的播放器 mpv)
brew install mpv --with-bundle
brew linkapps mpv
Recommend
-
75
centos6.9在命令行界面安装图形化桌面一、Linux桌面环境 X Windows系统 控制视频环境的两个基本元素是PC中的显卡和监视器,要实现图形化就要了解这两个元素。X Windows软件就是展现图形的核心元素。X Windows核心软件仅仅
-
49
问题描述:-Redhat 6.6Mini无法用自带yum仓库安装图形化界面;-执行Yum操作均提示This system is not registered to Red Hat Subscription Management-不断调整yum仓库方式,依旧提示Redhat默认自带的Yum源需要注册等;具体提示如下:This system is not registere...
-
34
把其中的id:3:initdefault中的3改为5,这样以后系统启动后将直接进入文本模式。 以下是配置引导进入图形模式的etc/inittab文件的部分内容: #Default runlevel.The runlevels used by RHS are: # 0-halt(Do NOT set initdefa...
-
10
在 Windows 中相信大家已经很熟悉使用 Xmanager(Xshell), MobaXterm, SecureCRT 通过 X11 实现 Linux 图形化界面显示,我的需求是在 macOS 下使用 iTerm2 作为 Terminal 实现 X11 图形化界面显示,网上大部分教程只提到安装 Xquartz 但并没有结合实际问题给出完...
-
15
JDK 内置图形界面工具:海阔凭鱼跃,天高任鸟飞
-
9
Python:一个简单易用的 Python GUI 图形化界面编程框架——PySimpleGUI By: taho On: 2021年7...
-
6
华硕(ASUS)路由器 RT-AC86U 简单图形界面方式设置IPTV单线复用 2021年8月12日450
-
6
文章目录 [显示] 电脑里的文件积累得越来越多,想要快速找一个文件就是一个麻烦事儿。 一个麻烦在于不知道文件在什么地方,这可以通过系统自带的文件管理器或者第三方的文件搜...
-
4
Win32简单图形界面程序逆向 前言 为了了解与学习底层知识,从 汇编开始 -> C语言 -> C++ -> PE文件 ,直至今天的Win32 API,着实学的令我头皮发麻(笑哭)。 就在昨天的课程中,老师布置...
-
4
一个Python图形界面库 - 迷途小书童的Note迷途小书童的Note 迷途小书童的Note >
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK