How to rotate a video within a GUI

0

Good night, I have a problem. I need to run a youtube video inside a GUI interface (with Python).

A user of the community helped me by providing the following code:

link

however, it was written using PyQt4. But all my final project is done in version 3 of python.

Someone could tell me how to do the same using PyQt5 or if I can install PyQt4 in version 3 of python (I've tried a lot).

Note: ideas with other modules are also very welcome.

    
asked by anonymous 14.07.2015 / 05:19

1 answer

1

So the only thing that comes into my head is to use a widget that renders html itself, exactly as it is proposed in the code you posted.

Making some changes, I managed to have a similar result in GNU / Linux:

import sys

from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QUrl
from PyQt5.QtWebEngineWidgets import QWebEngineView


app = QApplication(sys.argv)
web = QWebEngineView()

html = '<!doctype html><html><head></head><body><iframe width="560" height="315" src="https://www.youtube.com/embed/zqFPTkxu-Rc"frameborder="0" allowfullscreen></iframe></body></html>'
url = QUrl("https://www.youtube.com/")  
web.setHtml(html, url)

web.show()
app.exec()

The difference is that in version 5, there is no longer the QString class, and you can use standard Python strings instead.

In addition, instead of using the QWebView widget, I used QWebEngineView which, according to documentation , replaces QWebKit for more current support of HTML, CSS and Javascript. However, according to the same source, you may have trouble using this widget on windows.

If this is the case for you, maybe you should change your library. wxPython has html support, I just do not know how they support it for Python 3. In addition, you can take a look at GTK + , which also has a webkit that can solve your problem.

    
14.07.2015 / 08:11