aboutsummaryrefslogtreecommitdiffstats
path: root/examples/opengl/hellogl2/mainwindow.py
blob: 69b9b66fee40929e95b9ba29f586e9dafb1e718a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Copyright (C) 2023 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

from PySide6.QtCore import Slot, Qt
from PySide6.QtGui import QKeySequence
from PySide6.QtWidgets import QMainWindow, QMessageBox

from window import Window


class MainWindow(QMainWindow):

    def __init__(self):
        super().__init__()
        menuWindow = self.menuBar().addMenu("Window")
        menuWindow.addAction("Add new", QKeySequence(Qt.CTRL | Qt.Key_N),
                             self.onAddNew)
        menuWindow.addAction("Quit", QKeySequence(Qt.CTRL | Qt.Key_Q),
                             qApp.closeAllWindows)  # noqa: F821

        self.onAddNew()

    @Slot()
    def onAddNew(self):
        if not self.centralWidget():
            self.setCentralWidget(Window(self))
        else:
            QMessageBox.information(self, "Cannot Add Window()",
                                    "Already occupied. Undock first.")