我们从Python开源项目中,提取了以下21个代码示例,用于说明如何使用PyQt5.QtCore.Qt.Dialog()。
def createTypeGroupBox(self): self.typeGroupBox = QGroupBox("Type") self.windowRadioButton = self.createRadioButton("Window") self.dialogRadioButton = self.createRadioButton("Dialog") self.sheetRadioButton = self.createRadioButton("Sheet") self.drawerRadioButton = self.createRadioButton("Drawer") self.popupRadioButton = self.createRadioButton("Popup") self.toolRadioButton = self.createRadioButton("Tool") self.toolTipRadioButton = self.createRadioButton("Tooltip") self.splashScreenRadioButton = self.createRadioButton("Splash screen") self.windowRadioButton.setChecked(True) layout = QGridLayout() layout.addWidget(self.windowRadioButton, 0, 0) layout.addWidget(self.dialogRadioButton, 1, 0) layout.addWidget(self.sheetRadioButton, 2, 0) layout.addWidget(self.drawerRadioButton, 3, 0) layout.addWidget(self.popupRadioButton, 0, 1) layout.addWidget(self.toolRadioButton, 1, 1) layout.addWidget(self.toolTipRadioButton, 2, 1) layout.addWidget(self.splashScreenRadioButton, 3, 1) self.typeGroupBox.setLayout(layout)
def __init__(self, parent=None, flags=Qt.Dialog | Qt.FramelessWindowHint): super(VCProgressBar, self).__init__(parent, flags) self.parent = parent self.setWindowModality(Qt.ApplicationModal) self.setStyleSheet('QDialog { border: 2px solid #000; }') self._progress = QProgressBar(self) self._progress.setRange(0, 0) self._progress.setTextVisible(False) self._progress.setStyle(QStyleFactory.create('Fusion')) self._label = QLabel(self) self._label.setAlignment(Qt.AlignCenter) layout = QGridLayout() layout.addWidget(self._progress, 0, 0) layout.addWidget(self._label, 0, 0) self._timerprefix = QLabel('<b>Elapsed time:</b>', self) self._timerprefix.setObjectName('progresstimer') self._timervalue = QLabel(self) self._timervalue.setObjectName('progresstimer') timerlayout = QHBoxLayout() timerlayout.addWidget(self._timerprefix) timerlayout.addWidget(self._timervalue) self._timerwidget = QWidget(self) self._timerwidget.setLayout(timerlayout) self._timerwidget.hide() self._time = QTime() self._timer = QTimer(self) self._timer.timeout.connect(self.updateTimer) self.setLayout(layout) self.setFixedWidth(550)
def __init__(self, parent): super().__init__(parent=parent) self.setupUi(self) if parent: self.move( parent.window().frameGeometry().topLeft() + parent.window().rect().center() - self.rect().center() ) self.setWindowFlags(Qt.WindowTitleHint | Qt.Dialog) self.version.setText("Version: " + __version__) copyright_text = self.copyright.text() new_year = "2016-" + str(datetime.now().year) if datetime.now().year != 2016 else "2016" copyright_text = copyright_text.replace("2016", new_year) self.copyright.setText(copyright_text) self.button.clicked.connect(self.close)
def ask_for_password(self, title, label="Password"): if self._preset_password is not None: return self._preset_password input_dlg = QInputDialog(parent=self, flags=Qt.Dialog) input_dlg.setTextEchoMode(QLineEdit.Password) input_dlg.setWindowTitle(title) input_dlg.setLabelText(label) input_dlg.resize(500, 100) input_dlg.exec() return input_dlg.textValue()
def __init__(self, parent=None, flags=Qt.Dialog | Qt.WindowCloseButtonHint): super(Updater, self).__init__(parent, flags) self.parent = parent self.logger = logging.getLogger(__name__) self.api_github_latest = QUrl('https://api.github.com/repos/ozmartian/vidcutter/releases/latest') self.manager = QNetworkAccessManager(self) self.manager.finished.connect(self.done)
def __init__(self, parent=None, theme: str='light', title: str='Checking for updates', flags=Qt.Dialog | Qt.WindowCloseButtonHint): super(UpdaterMsgBox, self).__init__(parent, flags) self.parent = parent self.theme = theme self.setWindowTitle(title) self.setWindowModality(Qt.ApplicationModal) self.setObjectName('updaterdialog') self.loading = VCProgressBar(self.parent) self.loading.setText('contacting server') self.loading.setMinimumWidth(485) self.loading.show()
def switchTheme(self) -> None: if self.darkRadio.isChecked(): newtheme = 'dark' else: newtheme = 'light' if newtheme != self.parent.theme: # noinspection PyArgumentList mbox = QMessageBox(icon=QMessageBox.NoIcon, windowTitle='Restart required', minimumWidth=500, textFormat=Qt.RichText, objectName='genericdialog') mbox.setWindowFlags(Qt.Dialog | Qt.WindowCloseButtonHint) mbox.setText(''' <style> h1 { color: %s; font-family: "Futura-Light", sans-serif; font-weight: 400; } p { font-size: 15px; } </style> <h1>Warning</h1> <p>The application needs to be restarted in order to switch themes. Attempts will be made to reopen media files and add back all clip times from your clip index.</p> <p>Would you like to restart and switch themes now?</p>''' % ('#C681D5' if self.parent.theme == 'dark' else '#642C68')) mbox.setStandardButtons(QMessageBox.Yes | QMessageBox.No) mbox.setDefaultButton(QMessageBox.Yes) response = mbox.exec_() if response == QMessageBox.Yes: self.parent.settings.setValue('theme', newtheme) self.parent.parent.theme = newtheme self.parent.parent.parent.reboot() else: self.darkRadio.setChecked(True) if newtheme == 'light' else self.lightRadio.setChecked(True)
def __init__(self, parent=None, *args, **kwargs): super(WaitDialog, self).__init__(parent) self.label = QLabel(self) self.label.setAlignment(Qt.AlignCenter) self.setFixedSize(551, 401) self.setWindowOpacity(0.5) # set transparent self.setWindowFlags(Qt.Dialog | Qt.CustomizeWindowHint | Qt.FramelessWindowHint) self.setAttribute(Qt.WA_TranslucentBackground) # background transparent self.setContentsMargins(0, 0, 0, 0) config = Config() self.movie = QMovie(os.path.join(config.images, 'wait.gif')) self.label.setMovie(self.movie) self.movie.start()
def setWindowFlags(self, flags): super(PreviewWindow, self).setWindowFlags(flags) flag_type = (flags & Qt.WindowType_Mask) if flag_type == Qt.Window: text = "Qt.Window" elif flag_type == Qt.Dialog: text = "Qt.Dialog" elif flag_type == Qt.Sheet: text = "Qt.Sheet" elif flag_type == Qt.Drawer: text = "Qt.Drawer" elif flag_type == Qt.Popup: text = "Qt.Popup" elif flag_type == Qt.Tool: text = "Qt.Tool" elif flag_type == Qt.ToolTip: text = "Qt.ToolTip" elif flag_type == Qt.SplashScreen: text = "Qt.SplashScreen" else: text = "" if flags & Qt.MSWindowsFixedSizeDialogHint: text += "\n| Qt.MSWindowsFixedSizeDialogHint" if flags & Qt.X11BypassWindowManagerHint: text += "\n| Qt.X11BypassWindowManagerHint" if flags & Qt.FramelessWindowHint: text += "\n| Qt.FramelessWindowHint" if flags & Qt.WindowTitleHint: text += "\n| Qt.WindowTitleHint" if flags & Qt.WindowSystemMenuHint: text += "\n| Qt.WindowSystemMenuHint" if flags & Qt.WindowMinimizeButtonHint: text += "\n| Qt.WindowMinimizeButtonHint" if flags & Qt.WindowMaximizeButtonHint: text += "\n| Qt.WindowMaximizeButtonHint" if flags & Qt.WindowCloseButtonHint: text += "\n| Qt.WindowCloseButtonHint" if flags & Qt.WindowContextHelpButtonHint: text += "\n| Qt.WindowContextHelpButtonHint" if flags & Qt.WindowShadeButtonHint: text += "\n| Qt.WindowShadeButtonHint" if flags & Qt.WindowStaysOnTopHint: text += "\n| Qt.WindowStaysOnTopHint" if flags & Qt.WindowStaysOnBottomHint: text += "\n| Qt.WindowStaysOnBottomHint" if flags & Qt.CustomizeWindowHint: text += "\n| Qt.CustomizeWindowHint" self.textEdit.setPlainText(text)
def updatePreview(self): flags = Qt.WindowFlags() if self.windowRadioButton.isChecked(): flags = Qt.Window elif self.dialogRadioButton.isChecked(): flags = Qt.Dialog elif self.sheetRadioButton.isChecked(): flags = Qt.Sheet elif self.drawerRadioButton.isChecked(): flags = Qt.Drawer elif self.popupRadioButton.isChecked(): flags = Qt.Popup elif self.toolRadioButton.isChecked(): flags = Qt.Tool elif self.toolTipRadioButton.isChecked(): flags = Qt.ToolTip elif self.splashScreenRadioButton.isChecked(): flags = Qt.SplashScreen if self.msWindowsFixedSizeDialogCheckBox.isChecked(): flags |= Qt.MSWindowsFixedSizeDialogHint if self.x11BypassWindowManagerCheckBox.isChecked(): flags |= Qt.X11BypassWindowManagerHint if self.framelessWindowCheckBox.isChecked(): flags |= Qt.FramelessWindowHint if self.windowTitleCheckBox.isChecked(): flags |= Qt.WindowTitleHint if self.windowSystemMenuCheckBox.isChecked(): flags |= Qt.WindowSystemMenuHint if self.windowMinimizeButtonCheckBox.isChecked(): flags |= Qt.WindowMinimizeButtonHint if self.windowMaximizeButtonCheckBox.isChecked(): flags |= Qt.WindowMaximizeButtonHint if self.windowCloseButtonCheckBox.isChecked(): flags |= Qt.WindowCloseButtonHint if self.windowContextHelpButtonCheckBox.isChecked(): flags |= Qt.WindowContextHelpButtonHint if self.windowShadeButtonCheckBox.isChecked(): flags |= Qt.WindowShadeButtonHint if self.windowStaysOnTopCheckBox.isChecked(): flags |= Qt.WindowStaysOnTopHint if self.windowStaysOnBottomCheckBox.isChecked(): flags |= Qt.WindowStaysOnBottomHint if self.customizeWindowHintCheckBox.isChecked(): flags |= Qt.CustomizeWindowHint self.previewWindow.setWindowFlags(flags) pos = self.previewWindow.pos() if pos.x() < 0: pos.setX(0) if pos.y() < 0: pos.setY(0) self.previewWindow.move(pos) self.previewWindow.show()
def __init__(self, media, parent=None, flags=Qt.Dialog | Qt.WindowCloseButtonHint): super(VideoInfo, self).__init__(parent, flags) self.logger = logging.getLogger(__name__) self.media = media self.parent = parent self.setObjectName('videoinfo') self.setContentsMargins(0, 0, 0, 0) self.setWindowModality(Qt.ApplicationModal) self.setWindowTitle('Media information - {}'.format(os.path.basename(self.media))) self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) self.setMinimumSize(self.modes.get(self.parent.parent.scale)) metadata = '''<style> table { font-family: "Noto Sans UI", sans-serif; font-size: 13px; margin-top: -10px; } td i { font-family: "Noto Sans UI", sans-serif; font-weight: normal; font-style: normal; text-align: right; color: %s; white-space: nowrap; } td { font-weight: normal; text-align: right; } td + td { text-align: left; } h1, h2, h3 { color: %s; } </style> <div align="center">%s</div>''' % ('#C681D5' if self.parent.theme == 'dark' else '#642C68', '#C681D5' if self.parent.theme == 'dark' else '#642C68', self.parent.videoService.mediainfo(self.media)) content = QTextBrowser(self.parent) content.setStyleSheet('QTextBrowser { border: none; background-color: transparent; }') content.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) content.setHtml(metadata) keyframesButton = QPushButton('View keyframes', self) keyframesButton.clicked.connect(self.showKeyframes) okButton = QDialogButtonBox(QDialogButtonBox.Ok) okButton.accepted.connect(self.close) button_layout = QHBoxLayout() mediainfo_version = self.parent.videoService.cmdExec(self.parent.videoService.backends.mediainfo, '--version', True) if len(mediainfo_version) >= 2: mediainfo_version = mediainfo_version.split('\n')[1] mediainfo_label = QLabel('<div style="font-size:11px;"><b>Media information by:</b><br/>%s @ ' % mediainfo_version + '<a href="https://mediaarea.net" target="_blank">' + 'mediaarea.net</a></div>') button_layout.addWidget(mediainfo_label) button_layout.addStretch(1) button_layout.addWidget(keyframesButton) button_layout.addWidget(okButton) layout = QVBoxLayout() layout.addWidget(content) layout.addLayout(button_layout) self.setLayout(layout)
def open_path(self, path): """ Method used to open a path in the main window - closes the intro window and show the main. :param path: The path to open. """ main_window = MainFrame() self_center = self.mapToGlobal(self.rect().center()) main_center = main_window.mapToGlobal(main_window.rect().center()) main_window.move(self_center - main_center) main_window.open(path) main_window.show() self.close() if self.settings_dict["General"]["tutorial_advanced"]: main_window.setEnabled(False) tutorial = loadUi(join(cur_folder, "resources/templates/tutorial_advanced.ui")) tutorial.frame_node.resize(main_window.node_tree_view.size()) tutorial.frame_node.move( main_window.node_tree_view.mapTo(main_window, main_window.node_tree_view.pos()) ) tutorial.frame_preview.resize(main_window.tabWidget.size()) tutorial.frame_preview.move( main_window.tabWidget.mapTo(main_window, main_window.tabWidget.pos()) ) tutorial.frame_prop.resize(main_window.dockWidgetContents.size()) tutorial.frame_prop.move( main_window.dockWidgetContents.mapTo(main_window, main_window.dockWidgetContents.pos()) ) tutorial.frame_child.resize(main_window.dockWidgetContents_3.size()) tutorial.frame_child.move( main_window.dockWidgetContents_3.mapTo(main_window, main_window.dockWidgetContents_3.pos()) ) tutorial.button_exit.clicked.connect(lambda: main_window.setEnabled(True)) tutorial.button_exit.clicked.connect(tutorial.close) tutorial.setParent(main_window) tutorial.setWindowFlags(Qt.FramelessWindowHint | Qt.Dialog) tutorial.setAttribute(Qt.WA_TranslucentBackground) main_center = main_window.mapToGlobal(main_window.rect().center()) tutorial_center = tutorial.mapToGlobal(tutorial.rect().center()) tutorial.move(main_center - tutorial_center) tutorial.setEnabled(True) tutorial.exec_() self.settings_dict["General"]["tutorial_advanced"] = False self.settings_dict["General"]["show_intro"] = not self.check_intro.isChecked() self.settings_dict["General"]["show_advanced"] = self.check_advanced.isChecked() makedirs(join(expanduser("~"), ".fomod"), exist_ok=True) with open(join(expanduser("~"), ".fomod", ".designer"), "w") as configfile: set_encoder_options("json", indent=4) configfile.write(encode(self.settings_dict))