Exemplo n.º 1
0
class Browser(QObject):
	# pylint: disable=too-many-public-methods

	__execute_script_called = Signal(str)

	def __init__(self):
		super().__init__()

		self.app = QApplication([])

		self.webview = QWebView()
		self.webview.setAttribute(Qt.WA_DeleteOnClose)
		self.webview.destroyed.connect(self.app.quit)

		self.__execute_script_called.connect(self.__execute_script)

	def __execute_script(self, javascript_code: str):
		assert current_thread_is_main()
		self.webview.page().mainFrame().evaluateJavaScript(javascript_code)

	def execute_script(self, javascript_code: str):
		if current_thread_is_main():
			self.__execute_script(javascript_code)
		else:
			self.__execute_script_called.emit(javascript_code)

	def run(self, url):
		assert current_thread_is_main()
		self.webview.showFullScreen()
		self.webview.load(url)
		self.app.exec_()
Exemplo n.º 2
0
 def init_video(self):
     web = QWebView()
     web.showFullScreen()
     web.load(QUrl("http://www.google.com"))
     self.layout().addWidget(web)
Exemplo n.º 3
0
import sys
from PySide.QtCore import *
from PySide.QtGui import *
from PySide.QtWebKit import QWebView

app = QApplication(sys.argv)
web = QWebView()
web.showFullScreen()
web.load(QUrl("http://www.google.com"))
sys.exit(app.exec_())