summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjaseg <githubaccount@jaseg.net>2018-12-02 10:07:20 +0900
committerGitHub <noreply@github.com>2018-12-02 10:07:20 +0900
commit9b4faea03050b161328c4c83f67b407ad0b10c80 (patch)
tree0d3d6e996fadbe5a09de88621fb91ccdf75cf492
parent8ba7d27e799f87a074c37f88514f1ca5c4e9ec09 (diff)
parent85eaac93632b8b73506330da6bb49921ee625dc9 (diff)
downloadpython-mpv-9b4faea03050b161328c4c83f67b407ad0b10c80.tar.gz
python-mpv-9b4faea03050b161328c4c83f67b407ad0b10c80.tar.bz2
python-mpv-9b4faea03050b161328c4c83f67b407ad0b10c80.zip
Merge pull request #78 from trin94/patch-1
Readme: Add PyGtk embedding example
-rw-r--r--README.rst38
1 files changed, 38 insertions, 0 deletions
diff --git a/README.rst b/README.rst
index 7bf212c..3c1f5bd 100644
--- a/README.rst
+++ b/README.rst
@@ -170,6 +170,44 @@ PyQT embedding
win.show()
sys.exit(app.exec_())
+PyGtk embedding
+..............
+
+.. code:: python
+
+ #!/usr/bin/env python3
+ import gi
+
+ import mpv
+
+ gi.require_version('Gtk', '3.0')
+ from gi.repository import Gtk
+
+
+ class MainClass(Gtk.Window):
+
+ def __init__(self):
+ super(MainClass, self).__init__()
+ self.set_default_size(600, 400)
+ self.connect("destroy", self.on_destroy)
+
+ widget = Gtk.Frame()
+ self.add(widget)
+ self.show_all()
+
+ # Must be created >after< the widget is shown, else property 'window' will be None
+ self.mpv = mpv.MPV(wid=str(widget.get_property("window").get_xid()))
+ self.mpv.play("test.webm")
+
+ def on_destroy(self, widget, data=None):
+ self.mpv.terminate()
+ Gtk.main_quit()
+
+
+ if __name__ == '__main__':
+ application = MainClass()
+ Gtk.main()
+
Coding Conventions
------------------