summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjaseg <code@jaseg.net>2017-12-25 13:33:03 +0100
committerjaseg <code@jaseg.net>2017-12-25 13:33:03 +0100
commit4352b01e292f530327d32ac55bafb730274ab8cd (patch)
tree219b6b1a5de32998506c9951bba67e0fa18d9cf4
parent243414d5e09c20ca909b564a0a1e5d05a11db8ab (diff)
downloadpython-mpv-4352b01e292f530327d32ac55bafb730274ab8cd.tar.gz
python-mpv-4352b01e292f530327d32ac55bafb730274ab8cd.tar.bz2
python-mpv-4352b01e292f530327d32ac55bafb730274ab8cd.zip
README: Add PyQT embedding example
-rw-r--r--README.rst44
1 files changed, 42 insertions, 2 deletions
diff --git a/README.rst b/README.rst
index 3316896..7bf212c 100644
--- a/README.rst
+++ b/README.rst
@@ -58,7 +58,6 @@ Usage
player = mpv.MPV(ytdl=True)
player.play('https://youtu.be/DOmdB7D-pUU')
-
Threading
~~~~~~~~~
@@ -76,6 +75,9 @@ All API functions are thread-safe. If one is not, please file an issue on github
Advanced Usage
~~~~~~~~~~~~~~
+Logging, Properties, Python Key Bindings, Screenshots and youtube-dl
+....................................................................
+
.. code:: python
#!/usr/bin/env python3
@@ -112,6 +114,9 @@ Advanced Usage
del player
+Playlist handling
+.................
+
.. code:: python
#!/usr/bin/env python3
@@ -130,7 +135,42 @@ Advanced Usage
print(player.playlist)
player.wait_for_playback()
-Coding conventions
+PyQT embedding
+..............
+
+.. code:: python
+
+ #!/usr/bin/env python3
+ import mpv
+ import sys
+
+ from PyQt5.QtWidgets import *
+ from PyQt5.QtCore import *
+
+ class Test(QMainWindow):
+ def __init__(self, parent=None):
+ super().__init__(parent)
+ self.container = QWidget(self)
+ self.setCentralWidget(self.container)
+ self.container.setAttribute(Qt.WA_DontCreateNativeAncestors)
+ self.container.setAttribute(Qt.WA_NativeWindow)
+ player = mpv.MPV(wid=str(int(self.container.winId())),
+ vo='x11', # You may not need this
+ log_handler=print,
+ loglevel='debug')
+ player.play('test.webm')
+
+ app = QApplication(sys.argv)
+
+ # This is necessary since PyQT stomps over the locale settings needed by libmpv.
+ # This needs to happen after importing PyQT before creating the first mpv.MPV instance.
+ import locale
+ locale.setlocale(locale.LC_NUMERIC, 'C')
+ win = Test()
+ win.show()
+ sys.exit(app.exec_())
+
+Coding Conventions
------------------
The general aim is `PEP 8`_, with liberal application of the "consistency" section. 120 cells line width. Four spaces.