예제 #1
0
    def initUI(self):
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)
        qtRectangle = self.frameGeometry()
        centerPoint = QGuiApplication.screens()[0].geometry().center()
        qtRectangle.moveCenter(centerPoint)
        self.move(qtRectangle.topLeft())

        icon_size = 64

        icon = QPixmap(resource_path("icon.png"))
        self.icon_label.setPixmap(
            icon.scaled(
                icon_size,
                icon_size,
                transformMode=Qt.TransformationMode.SmoothTransformation,
            ))
        self.icon_label.setGeometry((self.rect().width() - icon_size) / 2, 10,
                                    icon_size, icon_size)
        self.monitor_error.setStyleSheet("QLabel { color: red}")
        self.monitor_error.setGeometry(140, 75, self.rect().width(), 20)

        QApplication.instance().screenAdded.connect(self.check_second_monitor)
        QApplication.instance().screenRemoved.connect(
            self.check_second_monitor)
        self.check_second_monitor()

        self.startButton.setToolTip("Start Game")
        self.startButton.move(280, 95)
        self.startButton.clicked.connect(self.init_game)
        self.startButton.setEnabled(False)

        self.randButton.setToolTip("Random Game")
        self.randButton.move(280, 120)
        # self.randButton.setFocus(False)
        self.randButton.clicked.connect(self.random)
        summary_margin = 50
        self.summary_label.setGeometry(
            summary_margin, 150,
            self.rect().width() - 2 * summary_margin, 40)
        self.summary_label.setAlignment(Qt.AlignmentFlag.AlignHCenter)

        self.gameid_label.move(120, 105)
        self.textbox.move(180, 100)
        self.textbox.resize(100, 40)
        self.textbox.textChanged.connect(self.show_summary)
        f = self.textbox.font()
        f.setPointSize(30)  # sets the size to 27
        self.textbox.setFont(f)

        self.player_view = PlayerView(self.rect() - QMargins(0, 210, 0, 0),
                                      parent=self)

        if DEBUG:
            self.textbox.setText(str(2534))  # EDIT

        self.show()
        print("Number of screens:", len(QApplication.instance().screens()))
예제 #2
0
    def __init__(self, game, alex=True, monitor=0):
        super().__init__()
        self.alex = alex
        self.setWindowTitle("Alex" if alex else "Board")

        colorpal = QPalette()
        colorpal.setColor(QPalette.ColorRole.Window, BLACK)
        self.setPalette(colorpal)

        # monitor = QDesktopWidget().screenGeometry(monitor)
        monitor = QGuiApplication.screens()[monitor].geometry()

        self.move(monitor.left(), monitor.top())  # move to monitor 0
        self.showFullScreen()

        self.boardwidget = BoardWidget(game, parent=self)
        self.boardwidget.move(
            self.geometry().width() / 2 -
            self.boardwidget.geometry().width() / 2, 0)
        self.boardwidget.update()

        self.scoreboard = ScoreWidget(game, parent=self)
        self.finalanswerwindow = FinalAnswerWidget(game, parent=self)
        self.finalanswerwindow.setVisible(False)

        self.borderwidget = BorderWidget(game,
                                         self.boardwidget.geometry(),
                                         parent=self)
        self.borderwidget.setGeometry(0, 0,
                                      self.size().width(),
                                      self.boardwidget.size().height())
        self.borderwidget.stackUnder(self.boardwidget)

        print("   ",
              self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose, True))

        self.game = game
        self.game.dc += self
        self.show()
예제 #3
0
    def __init__(self, host):
        QMainWindow.__init__(self)
        self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
        screen = QGuiApplication.screens()[1]

        screen_width = screen.size().width()
        display_width = int(0.7 * screen_width)
        display_height = int(0.2 * display_width)
        font_size = int(0.06 * display_width)

        self.setWindowFlags(Qt.WindowType.WindowStaysOnTopHint
                            | Qt.WindowType.FramelessWindowHint
                            | Qt.WindowType.X11BypassWindowManagerHint)
        self.setGeometry(
            QStyle.alignedRect(
                Qt.LayoutDirection.LeftToRight,
                Qt.AlignmentFlag.AlignCenter,
                QSize(display_width, display_height),
                screen.geometry(),
            ))

        font = QFont()
        font.setPointSize(font_size)
        self.label = QLabel("http://" + host, self)
        self.label.setGeometry(self.rect() -
                               QMargins(0, 0, 0,
                                        self.rect().height() // 2))
        self.label.setAlignment(Qt.AlignmentFlag.AlignCenter)
        self.label.setFont(font)

        self.playerview = PlayerView(self.rect() -
                                     QMargins(0,
                                              self.rect().height() // 2, 0, 0),
                                     fontsize=OVERLAYFONTSIZE,
                                     parent=self)

        self.show()
예제 #4
0
import sys

from PyQt6.QtGui import QGuiApplication
from PyQt6.QtQml import QQmlApplicationEngine

app = QGuiApplication(sys.argv)

engine = QQmlApplicationEngine()
engine.quit.connect(app.quit)
engine.load('main.qml')

sys.exit(app.exec())
예제 #5
0
import sys
import os

from PyQt6.QtGui import QGuiApplication, QIcon
from PyQt6.QtQml import QQmlApplicationEngine

from func import Backend


os.environ['QT_QUICK_BACKEND'] = 'software'

app = QGuiApplication(sys.argv)
app.setWindowIcon(QIcon('UI/images/disc_logo.png'))

engine = QQmlApplicationEngine()
engine.load('UI/main.qml')

back_end = Backend()

engine.rootObjects()[0].setProperty('backend', back_end)

officer = back_end.get_officer()
back_end.updateOfficer.emit(officer)
back_end.get_officer_staged_collections(officer)
back_end._get_summary()
back_end._get_clients()

engine.quit.connect(app.quit)

sys.exit(app.exec())
예제 #6
0
    # if files exist
    elif os.path.exists(sys.argv[1]):
        """
        Qt Charts require QApplication.
        And so we use that if the qml code imports QtCharts
        We can create the Qt Application object in an if..else..
        statement but not in a function
        """
        # Check if it import QtCharts
        chk = Check(sys.argv[1])
        contains_qtchart = chk.check_for_qtcharts()
        # use that to decide what to use
        if contains_qtchart:
            app = QApplication(sys.argv)
        else:
            app = QGuiApplication(sys.argv)

        app.setWindowIcon(QIcon(':/icons/logo.png'))
        app.aboutToQuit.connect(clean_up)
        engine = QQmlApplicationEngine()
    else:
        print('qmlview error: File Not Found [{0}]'.format(sys.argv[1]))
        print('Please write Filepath in full.')
        print('    Eg:', PATH_EG)
        print('or Do: qmlview -help or --help: for help')
        house_keeping(2)

    # check if it comes with parameters

    if len(sys.argv) > 2: