From 18b5e365d376d14836d7a13945e45b85e23e56c0 Mon Sep 17 00:00:00 2001 From: talksik Date: Tue, 18 Jul 2023 12:09:35 -0700 Subject: [PATCH] adding in video playing successfully --- .gitignore | 1 + hello_world.py | 33 +++++++++++++++++++++++++++++++++ main.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 .gitignore create mode 100644 hello_world.py create mode 100644 main.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0a764a4 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +env diff --git a/hello_world.py b/hello_world.py new file mode 100644 index 0000000..a167272 --- /dev/null +++ b/hello_world.py @@ -0,0 +1,33 @@ +import sys +import random +from PySide6 import QtCore, QtWidgets, QtGui + +class MyWidget(QtWidgets.QWidget): + def __init__(self): + super().__init__() + + self.hello = ["Hallo Welt", "Hei maailma", "Hola Mundo", "Привет мир"] + + self.button = QtWidgets.QPushButton("Click me!") + self.text = QtWidgets.QLabel("Hello World", + alignment=QtCore.Qt.AlignCenter) + + self.layout = QtWidgets.QVBoxLayout(self) + self.layout.addWidget(self.text) + self.layout.addWidget(self.button) + + self.button.clicked.connect(self.magic) + + @QtCore.Slot() + def magic(self): + self.text.setText(random.choice(self.hello)) + +if __name__ == "__main__": + app = QtWidgets.QApplication([]) + + widget = MyWidget() + widget.resize(800, 600) + widget.show() + + sys.exit(app.exec()) + diff --git a/main.py b/main.py new file mode 100644 index 0000000..31108f4 --- /dev/null +++ b/main.py @@ -0,0 +1,42 @@ +import sys +import random +from PySide6 import QtCore, QtWidgets, QtGui, QtMultimedia, QtMultimediaWidgets + +class MyWidget(QtWidgets.QWidget): + def __init__(self): + super().__init__() + + self.hello = ["Hallo Welt", "Hei maailma", "Hola Mundo", "Привет мир"] + + self.button = QtWidgets.QPushButton("Click me!") + self.text = QtWidgets.QLabel("Hello World", + alignment=QtCore.Qt.AlignCenter) + + self.player = QtMultimedia.QMediaPlayer() + self.player.setSource(QtCore.QUrl("http://techslides.com/demos/sample-videos/small.mp4")) + videoWidget = QtMultimediaWidgets.QVideoWidget() + self.player.setVideoOutput(videoWidget) + videoWidget.show() + self.player.play() + + self.layout = QtWidgets.QVBoxLayout(self) + self.layout.addWidget(self.text) + self.layout.addWidget(self.button) + self.layout.addWidget(videoWidget) + + self.button.clicked.connect(self.magic) + + @QtCore.Slot() + def magic(self): + self.text.setText(random.choice(self.hello)) + +if __name__ == "__main__": + app = QtWidgets.QApplication([]) + + widget = MyWidget() + widget.resize(800, 600) + widget.show() + + sys.exit(app.exec()) + +