Readme: Add PyGtk embedding example

This commit is contained in:
Elias 2018-12-01 21:54:33 +01:00 committed by GitHub
parent 8ba7d27e79
commit 85eaac9363
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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
------------------