Page 1 of 1

Third monitor to display queue and venue advertising

Posted: Mon Feb 06, 2023 9:19 am
by Fensom1
I've created a little script with python and pyside6 to display the queue and display an advertisement. the queue will slowly scroll. I haven't yet added the code to display it on the third screen, but I will update it soon. Have a play around and change to your needs. You will just need to update the web address to whatever your proxy is. Just go to connect karaoke, enter your show name and the proxy will show in your address bar.

I will update as I refine, but feel free to change timing and code to your requirements.
I'm only learning Python so I'm not an expert, but I can help out a little for those who need it.


Code: Select all

import sys
from PySide6.QtCore import QUrl, QTimer
from PySide6.QtGui import QPixmap
from PySide6.QtWidgets import QApplication, QHBoxLayout, QLabel, QMainWindow, QPushButton, QVBoxLayout, QWidget, \
    QGraphicsOpacityEffect
from PySide6.QtWebEngineWidgets import QWebEngineView


class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()

        self.setWindowTitle("Website and Image Display")
        self.resize(800, 600)

        self.web_view = QWebEngineView()
        self.image_label = QLabel()
        self.stop_button = QPushButton("Stop")
        self.stop_button.clicked.connect(self.close)

       # self.web_view.setGraphicsEffect(QGraphicsOpacityEffect(self.web_view))
        # self.image_label.setGraphicsEffect(QGraphicsOpacityEffect(self.image_label))

        layout = QVBoxLayout()
        layout.addWidget(self.web_view)
        layout.addWidget(self.image_label)
        layout.addWidget(self.stop_button)

        central_widget = QWidget()
        central_widget.setLayout(layout)
        self.setCentralWidget(central_widget)

        self.timer = QTimer()
        self.timerScroll = QTimer()
        self.timer.timeout.connect(self.onTimeout)
        self.timerScroll.timeout.connect(self.scroll_page)

        self.showWebsite()
        self.timerScroll.start(100)

    def showWebsite(self):
        print("we are showing queue again")
        self.image_label.hide()
        self.web_view.load(QUrl("https://connectkaraoke.com/proxy/YOUR_PROXY/queue"))
        self.web_view.show()
        self.timerScroll.start(100)
        self.timer.start(50000)

    def showImage(self):
        print("we are now showing image")
        self.web_view.hide()
        # swap out meton.jpg with your advertising image
        self.image_label.setPixmap(QPixmap("meton.jpg"))
        self.image_label.show()
        self.timer.start(10000)

    def onTimeout(self):
        if self.web_view.isVisible():
            self.showImage()
        else:
            self.showWebsite()

    def scroll_page(self):

        self.web_view.page().runJavaScript("window.scrollBy(0,1);")
        print("we should be scrolling")



if __name__ == '__main__':
    app = QApplication(sys.argv)
    window = MainWindow()
    window.showFullScreen()
    sys.exit(app.exec_())