Python PyQt5 模块,QtWidgets() 实例源码

我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用PyQt5.QtWidgets()

项目:StarCraft-Casting-Tool    作者:teampheenix    | 项目源码 | 文件源码
def showAbout(self):
        """Show subwindow with about info."""
        html = markdown2.markdown_path(
            scctool.settings.getAbsPath("src/about.md"))

        html = html.replace("%VERSION%", scctool.__version__)
        if(not scctool.__new_version__):
            new_version = _("StarCraft Casting Tool is up to date.")
        else:
            new_version = _("The new version {} is available!").format(
                scctool.__latest_version__)
        html = html.replace('%NEW_VERSION%', new_version)

        # use self as parent here
        PyQt5.QtWidgets.QMessageBox.about(
            self, _("StarCraft Casting Tool - About"), html)
项目:StarCraft-Casting-Tool    作者:teampheenix    | 项目源码 | 文件源码
def closeEvent(self, event):
        """Close and clean up window."""
        try:
            try:
                if(self.mysubwindow1 and self.mysubwindow1.isVisible()):
                    self.mysubwindow1.close()
                if(self.mysubwindow2 and self.mysubwindow2.isVisible()):
                    self.mysubwindow2.close()
                if(self.mysubwindow3 and self.mysubwindow3.isVisible()):
                    self.mysubwindow3.close()
                if(self.mysubwindow4 and self.mysubwindow4.isVisible()):
                    self.mysubwindow4.close()
            finally:
                self.settings.setValue("geometry", self.saveGeometry())
                self.settings.setValue("windowState", self.saveState())
                self.controller.cleanUp()
                PyQt5.QtWidgets.QMainWindow.closeEvent(self, event)
                # event.accept()
        except Exception as e:
            module_logger.exception("message")
项目:StarCraft-Casting-Tool    作者:teampheenix    | 项目源码 | 文件源码
def updateMapCompleters(self):
        """Update the auto completers for maps."""
        for i in range(self.max_no_sets):
            completer = PyQt5.QtWidgets.QCompleter(
                scctool.settings.maps, self.le_map[i])
            completer.setCaseSensitivity(PyQt5.QtCore.Qt.CaseInsensitive)
            completer.setCompletionMode(
                PyQt5.QtWidgets.QCompleter.InlineCompletion)
            completer.setWrapAround(True)
            self.le_map[i].setCompleter(completer)
项目:StarCraft-Casting-Tool    作者:teampheenix    | 项目源码 | 文件源码
def createHorizontalGroupBox(self):
        """Create horizontal group box for tasks."""
        try:
            self.horizontalGroupBox = PyQt5.QtWidgets.QGroupBox(_("Tasks"))
            layout = PyQt5.QtWidgets.QHBoxLayout()

            self.pb_twitchupdate = PyQt5.QtWidgets.QPushButton(
                _("Update Twitch Title"))
            self.pb_twitchupdate.clicked.connect(self.updatetwitch_click)

            self.pb_nightbotupdate = PyQt5.QtWidgets.QPushButton(
                _("Update Nightbot"))
            self.pb_nightbotupdate.clicked.connect(self.updatenightbot_click)

            self.pb_resetscore = PyQt5.QtWidgets.QPushButton(_("Reset Score"))
            self.pb_resetscore.clicked.connect(self.resetscore_click)

            self.pb_obsupdate = PyQt5.QtWidgets.QPushButton(
                _("Update OBS Data"))
            self.pb_obsupdate.clicked.connect(self.updateobs_click)

            layout.addWidget(self.pb_twitchupdate)
            layout.addWidget(self.pb_nightbotupdate)
            layout.addWidget(self.pb_resetscore)
            layout.addWidget(self.pb_obsupdate)

            self.horizontalGroupBox.setLayout(layout)
        except Exception as e:
            module_logger.exception("message")
项目:StarCraft-Casting-Tool    作者:teampheenix    | 项目源码 | 文件源码
def logoDialog(self, button):
        """Open dialog for team logo."""
        # options = PyQt5.QtWidgets.QFileDialog.Options()
        # options |= PyQt5.QtWidgets.QFileDialog.DontUseNativeDialog
        fileName, status = PyQt5.QtWidgets.QFileDialog.getOpenFileName(
            self, _("Select Team Logo"), "", _("Support Images ({})").format("*.png *.jpg"))
        if fileName:
            try:
                os.remove(scctool.settings.OBSdataDir +
                          "/logo" + str(button) + ".png")
            except:
                pass
            try:
                os.remove(scctool.settings.OBSdataDir +
                          "/logo" + str(button) + ".jpg")
            except:
                pass

            base, ext = os.path.splitext(fileName)
            ext = ext.split("?")[0]
            fname = scctool.settings.OBSdataDir + "/logo" + str(button) + ext

            shutil.copy(fileName, fname)
            self.controller.updateLogos()
            self.controller.ftpUploader.cwd(scctool.settings.OBSdataDir)
            self.controller.ftpUploader.upload(
                fname, "logo" + str(button) + ext)
            self.controller.ftpUploader.cwd("..")
            self.controller.matchData.metaChanged()
            self.controller.matchData.updateScoreIcon()
项目:StarCraft-Casting-Tool    作者:teampheenix    | 项目源码 | 文件源码
def __init__(self, controller, app, translator):
        """Init the main window."""
        try:
            super(MainWindow, self).__init__()

            self.trigger = True
            self.controller = controller
            self.translator = translator

            self.createFormMatchDataBox()
            self.createTabs()
            self.createHorizontalGroupBox()
            self.createBackgroundTasksBox()

            self.createMenuBar()

            mainLayout = PyQt5.QtWidgets.QVBoxLayout()
            mainLayout.addWidget(self.tabs, 0)
            mainLayout.addWidget(self.fromMatchDataBox, 1)
            mainLayout.addWidget(self.backgroundTasksBox, 0)
            mainLayout.addWidget(self.horizontalGroupBox, 0)

            self.setWindowTitle(
                "StarCraft Casting Tool v{}".format(scctool.__version__))

            self.window = PyQt5.QtWidgets.QWidget()
            self.window.setLayout(mainLayout)
            self.setCentralWidget(self.window)

            # self.size
            self.statusBar()

            self.progressBar = BusyProgressBar()

            # self.progressBar.setMaximumHeight(20)
            self.progressBar.setMaximumWidth(160)
            self.progressBar.setMinimumWidth(160)
            self.progressBar.setVisible(False)
            self.progressBar.setText(_("FTP Transfer in progress..."))
            self.statusBar().addPermanentWidget(self.progressBar)

            self.app = app
            self.controller.setView(self)
            self.controller.refreshButtonStatus()

            self.processEvents()
            self.settings = PyQt5.QtCore.QSettings(
                "team pheeniX", "StarCraft Casting Tool")
            self.restoreGeometry(self.settings.value(
                "geometry", self.saveGeometry()))
            self.restoreState(self.settings.value(
                "windowState", self.saveState()))

            self.mysubwindow1 = None
            self.mysubwindow2 = None
            self.mysubwindow3 = None
            self.mysubwindow4 = None

            self.show()
        except Exception as e:
            module_logger.exception("message")
项目:ultimate-tic-tac-toe    作者:stoimenoff    | 项目源码 | 文件源码
def testCreateRadio(self):
        radio = self.menu.createRadio('text', 123)
        self.assertIsInstance(radio, PyQt5.QtWidgets.QRadioButton)
        self.assertEqual(radio.id, 123)
        self.assertEqual(radio.text(), 'text')
项目:ultimate-tic-tac-toe    作者:stoimenoff    | 项目源码 | 文件源码
def testCreateDifficultyMenu(self):
        box = self.menu.createDifficultyMenu()
        self.assertIsInstance(box, PyQt5.QtWidgets.QGroupBox)
        for i in range(3):
            try:
                radio = box.layout().itemAt(i).widget()
                self.assertIsInstance(radio, PyQt5.QtWidgets.QRadioButton)
                self.assertEqual(radio.id, i + 1)
            except Exception:
                self.fail('Radio error')
        fake = box.layout().itemAt(4).widget()
        self.assertFalse(fake)
项目:ultimate-tic-tac-toe    作者:stoimenoff    | 项目源码 | 文件源码
def testCreateLabel(self):
        label = self.game.createLabel('test')
        self.assertIsInstance(label, PyQt5.QtWidgets.QLabel)
        self.assertEqual(label.text(), 'test')
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def __init__(self, package):
        UIParser.__init__(self, QtCore, QtGui, QtWidgets, LoaderCreatorPolicy(package))
项目:PyQt5-for-Maya2017    作者:zclongpop123    | 项目源码 | 文件源码
def __init__(self, package):
        UIParser.__init__(self, QtCore, QtGui, QtWidgets, LoaderCreatorPolicy(package))