Home:ALL Converter>Pyqt Show Widget in two monitors at the same time

Pyqt Show Widget in two monitors at the same time

Ask Time:2021-09-22T05:31:13         Author:RBenet

Json Formatter

I'm doing an aplication to show results of a race.

When a rider arrives, a decoder take arrival time, I read this information by Serial Port or TC/IP Port. I decode this information and show rider time and the averall classification of all riders.

The riders arrives every 30 seconds or less.

I want to show this results in a external TV or Monitor. I can't see this monitor, that is why I want to see the widget that shows the results simultaneously on my monitor and the external monitor.

The results are showed in a QTableView inside a QMainWindow.

I have simplified the program code to be able to publish the question:

from PyQt5 import QtCore
from PyQt5.QtWidgets import QGridLayout,QWidget, QApplication, QPushButton,QLabel,QMainWindow,QStatusBar
from PyQt5.QtWidgets import QApplication, QDesktopWidget, QMainWindow
import sys


class ShowResults(QMainWindow):
    def __init__(self):
        super().__init__()
        
        self.resize(600,600)
        display_monitor = 1
        monitor = QDesktopWidget().screenGeometry(display_monitor)
        self.move(monitor.left(), monitor.top())
        self.showFullScreen() 
                
        self.create_GUI()
             
    def create_GUI(self):
           
        central_widget=QWidget()
        layout=QGridLayout(central_widget)
        self.setCentralWidget(central_widget)
        pb_show_times=QPushButton('START')

        layout.addWidget(pb_show_times,1,1)
             

app = QApplication(sys.argv)
print('Number of Monitors ',len(app.screens()))
ShowResults()
sys.exit(app.exec_())

Author:RBenet,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/69275776/pyqt-show-widget-in-two-monitors-at-the-same-time
yy