コード例 #1
0
    def __init__(self):
        super(Dialog, self).__init__()
        self.createMenu()
        self.createHorizontalGroupBox()
        self.createGridGroupBox()
        self.createFormGroupBox()

        bigEditor = QTextEdit()
        bigEditor.setPlainText(
            "This widget takes up all the remaining space in the top-level layout.")
        buttonBox = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        buttonBox.accepted.connect(self.accept)
        buttonBox.rejected.connect(self.reject)
        mainLayout = QVBoxLayout()
        mainLayout.setMenuBar(self.menuBar)
        mainLayout.addWidget(self.horizontalGroupBox)
        mainLayout.addWidget(self.gridGroupBox)
        mainLayout.addWidget(self.formGroupBox)
        mainLayout.addWidget(bigEditor)
        mainLayout.addWidget(buttonBox)
        self.setLayout(mainLayout)

        self.setWindowTitle("Basic Layouts")
コード例 #2
0
ファイル: main_window.py プロジェクト: BD-lab/gui
class MainWindow(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        self.setFixedSize(400, 200)
        self.setWindowTitle("Clinic")

        # Other windows
        self.window = None
        self.ui = None

        # Widgets
        self.menu = QMenuBar()
        self.file_menu = self.menu.addMenu("Plik")
        self.help_menu = self.menu.addMenu("Pomoc")
        self.button1 = QPushButton("Wybierz pacjenta")
        self.button1.setMinimumHeight(50)
        self.button2 = QPushButton("Dodaj pacjenta")
        self.button2.setMinimumHeight(50)

        # Menu
        self.exit_action = QAction("Wyjdź")
        self.help_action = QAction("Pomoc")
        self.about_action = QAction("O programie")
        self.file_menu.addAction(self.exit_action)
        self.help_menu.addAction(self.help_action)
        self.help_menu.addAction(self.about_action)

        # Layout
        self.layout = QVBoxLayout()
        self.layout.addWidget(self.button1)
        self.layout.addWidget(self.button2)
        self.layout.setMenuBar(self.menu)
        self.setLayout(self.layout)

        # Actions
        self.button1.clicked.connect(self.show_choose_patient)
        self.button2.clicked.connect(self.show_add_patient)
        self.exit_action.triggered.connect(self.close)
        self.help_action.triggered.connect(self.show_help_dialog)
        self.about_action.triggered.connect(self.show_about_dialog)

    @Slot()
    def show_choose_patient(self):
        self.window = QMainWindow()
        self.ui = Ui_ChoosePatientWindow()
        self.ui.setupUi(self.window)
        self.window.show()

    @Slot()
    def show_add_patient(self):
        self.window = QMainWindow()
        self.ui = Ui_AddPatientWindow()
        self.ui.setupUi(self.window)
        self.window.show()

    @Slot()
    def show_help_dialog(self):
        window = HelpDialog(parent=self)
        window.show()

    @Slot()
    def show_about_dialog(self):
        window = AboutDialog(parent=self)
        window.show()