我们从Python开源项目中,提取了以下27个代码示例,用于说明如何使用PyQt5.QtCore.Qt.FramelessWindowHint()。
def progress_start(title: str = '', length: int = 100, label: str = ''): MainUiProgress.progress = QProgressDialog() MainUiProgress.progress.setWindowFlags(Qt.FramelessWindowHint) MainUiProgress.progress.setWindowFlags(Qt.WindowTitleHint) MainUiProgress.progress.setMinimumWidth(400) from PyQt5.QtWidgets import QPushButton # QString() seems to be deprecated in v5 # PyQt does not support setCancelButton(0) as it expects a QPushButton instance # Get your shit together, Qt ! MainUiProgress.progress.findChild(QPushButton).hide() MainUiProgress.progress.setMinimumDuration(1) MainUiProgress.progress.setWindowModality(Qt.ApplicationModal) MainUiProgress.progress.setCancelButtonText('') MainUiProgress.progress.setWindowIcon(QIcon(':/ico/app.ico')) MainUiProgress.progress.setWindowTitle(title) MainUiProgress.progress.setLabelText(label) MainUiProgress.progress.setMaximum(length) MainUiProgress.progress.show()
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, icon: str, parent=None, f=Qt.Dialog | Qt.FramelessWindowHint): super(Notification, self).__init__(parent, f) self.parent = parent self.theme = self.parent.theme self.setObjectName('notification') self.setContentsMargins(10, 10, 10, 10) self.shown.connect(lambda: QTimer.singleShot(self.duration * 1000, self.fadeOut)) self.setWindowModality(Qt.ApplicationModal) self.setMinimumWidth(550) self._title, self._message = '', '' self.buttons = [] self.msgLabel = QLabel(self._message, self) self.msgLabel.setWordWrap(True) logo_label = QLabel('<img src="{}" width="82" />'.format(icon), self) logo_label.setFixedSize(82, 82) self.left_layout = QVBoxLayout() self.left_layout.addWidget(logo_label) layout = QHBoxLayout() layout.addStretch(1) layout.addLayout(self.left_layout) layout.addSpacing(10) layout.addWidget(self.msgLabel, Qt.AlignVCenter) layout.addStretch(1) self.setLayout(layout)
def __init__(self): QWidget.__init__(self) self.setWindowFlags(Qt.FramelessWindowHint|Qt.WindowStaysOnTopHint) self.setFixedSize(400, 70) main_vbox = QVBoxLayout() hbox= QHBoxLayout() hbox.setContentsMargins(0, 0, 0, 0) self.progress = gpvdm_progress() self.spinner=spinner() hbox.addWidget(self.progress, 0) hbox.addWidget(self.spinner, 0) w=QWidget() w.setLayout(hbox) main_vbox.addWidget(w,0) self.label=QLabel() self.label.setText(_("Running")+"...") main_vbox.addWidget(self.label) self.setLayout(main_vbox)
def __init__(self, parent=None): super(CompleterWidget, self).__init__(parent) ui_dir_path = os.path.dirname(__file__) ui_file_path = os.path.join(ui_dir_path, 'completer_widget.ui') uic.loadUi(ui_file_path, self) self.setWindowFlags(Qt.FramelessWindowHint | Qt.Tool) self.func_list_widget = QListWidget() self.func_list_widget.setFixedWidth(200) self.func_list_widget.setSizeAdjustPolicy(QListWidget.AdjustToContents) self.func_list_layout.insertWidget(0, self.func_list_widget) self.desc_text_browser.setSizeAdjustPolicy(QTextBrowser.AdjustToContents) self.func_list_widget.setFocusPolicy(Qt.NoFocus)
def __init__(self, parent=None): super(ShapedClock, self).__init__(parent, Qt.FramelessWindowHint | Qt.WindowSystemMenuHint) timer = QTimer(self) timer.timeout.connect(self.update) timer.start(1000) quitAction = QAction("E&xit", self, shortcut="Ctrl+Q", triggered=QApplication.instance().quit) self.addAction(quitAction) self.setContextMenuPolicy(Qt.ActionsContextMenu) self.setToolTip("Drag the clock with the left mouse button.\n" "Use the right mouse button to open a context menu.") self.setWindowTitle(self.tr("Shaped Analog Clock"))
def __init__(self, parent=None): QWidget.__init__(self, parent) allLayout = QVBoxLayout() self.l1 = QListWidget(self) self.l1.setObjectName("search_result_list") self.l1.setViewMode(QListView.ListMode) # self.l1.currentItemChanged.connect(self.f1click) self.l1.itemDoubleClicked.connect(self.item_dclick) allLayout.addWidget(self.l1) self.setLayout(allLayout) # self.setWindowFlags(Qt.FramelessWindowHint | Qt.Popup) # self.setFocusPolicy(Qt.ClickFocus) # self.setAttribute(Qt.WA_ShowWithoutActivating) # self.l1.setAttribute(Qt.WA_ShowWithoutActivating) self.setFocusPolicy(Qt.StrongFocus) # self.l1.setFocusPolicy(Qt.NoFocus) # print(parent.finder) # self.setFocusProxy(parent.finder)
def __init__(self, app, parent): super(__class__, self).__init__() uic.loadUi(app.theme["ui_path"] + "/ConnectingDialog.ui", self) self.app = app self.parent = parent self.setWindowFlags(Qt.FramelessWindowHint) self.connectingExitButton.clicked.connect(sysexit) self.setWindowTitle('Connecting') self.setWindowIcon(QIcon(app.theme["path"] + "/trayicon.png")) self.app.connectingDialog = self width = self.frameGeometry().width() height = self.frameGeometry().height() self.setFixedSize(width, height) # Methods for moving window
def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.setGeometry(100, 100, 320, 480) self.setFixedSize(320, 480) self.setWindowTitle("ShuffleNet") #self.setWindowFlags(Qt.FramelessWindowHint) self.setAttribute(Qt.WA_TranslucentBackground, True) self.iTunes = iTunes() self.r_song = [] self.currentSongID = '-1' self.songAdded = False pickle_file = "itl.p" self.itl = pickle.load(open(pickle_file, "rb")) self.pm = PredictModel() self.song_queue = [] self.song_changing = False input_file = open(os.path.join("", 'input.p'), 'rb') input_file_data = pickle.load(input_file) self.int_to_key = input_file_data['itk'] self.key_to_int = input_file_data['kti'] self.best_recommend = None self.drawUI()
def init_ui(self): self.setFixedSize(700,600) self.assemble() self.set_styles() self.aux = QPoint(200,300) self.setWindowFlags(Qt.FramelessWindowHint) # self.setAttribute(Qt.WA_TranslucentBackground)
def __init__(self,parent=None): myo.Ui_MainWindow.__init__(self,parent) self.setWindowFlags(Qt.FramelessWindowHint) f = QFile("D:\MyoSEMG\BorderlessWindow.css") if not f.exists(): self.statusBar().showMessage("Unable to load stylesheet, file not found in resources") else: f.open(QFile.ReadOnly | QFile.Text) ts = QTextStream(f) stylesheet = ts.readAll() self.setStyleSheet(stylesheet) title_bar = QtWidgets.QWidget() title_bar.pushButtonMinimize = QtWidgets.QToolButton() title_bar.pushButtonMinimize.setIcon(QtGui.QIcon('Icons/Minimize.png')) title_bar.pushButtonMaxmize = QtWidgets.QToolButton() title_bar.pushButtonMaxmize.setIcon(QtGui.QIcon('Icons/Maxmize.png')) title_bar.pushButtonClose = QtWidgets.QToolButton() title_bar.pushButtonClose.setIcon(QtGui.QIcon('Icons/Close.png')) title_bar.pushButtonMinimize.setMinimumHeight(10) title_bar.pushButtonClose.setMinimumHeight(10) title_bar.pushButtonMaxmize.setMinimumHeight(10) label = QtWidgets.QLabel(self) label.setText("MyoSEMG") title_bar.setWindowTitle("MyoSEMG") hbox = QtWidgets.QHBoxLayout() hbox.addWidget(label) hbox.addWidget(title_bar.pushButtonMinimize) hbox.addWidget(title_bar.pushButtonMaxmize) hbox.addWidget(title_bar.pushButtonClose) hbox.insertStretch(1,500) hbox.setSpacing(0) self.setSizePolicy(QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Fixed) self.maxNormal = False title_bar.pushButtonClose.clicked().connect(self.close) title_bar.pushButtonMinimize.clicked.connect(self.showSmall) title_bar.pushButtonMaxmize.clicked.connect(self.showMaxRestore)
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 __init__(self, parent = None, name = "", head = "", mood = "", pic1 = "", pic2 = "", pic3 = ""): super(ToolTip, self).__init__(parent) self.setWindowFlags(Qt.ToolTip | Qt.FramelessWindowHint) self.setupUi(self, name, head, mood, pic1, pic2, pic3) print("id: ", id(self)) self.showing = False
def __init__(self, parent=None, flags=None, message=None): self.message = message if (not flags): flags = Qt.FramelessWindowHint super(ProgressBar, self).__init__(parent=parent, flags=flags) vbox = QVBoxLayout() vbox.addStretch(1) lab = QLabel(message, self) vbox.addWidget(lab) pb = QProgressBar() pb.setRange(0, 0) vbox.addWidget(pb) self.setLayout(vbox)
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_ui(self): # self.setGeometry(300, 300, 300, 220) self.center() self.setWindowTitle('Kiosk') # self.setWindowIcon(QIcon('web.png')) self.show() # programName("calc.exe"); # QStringList arguments; # process_ptr = QProcess(self); # process_ptr.conn # QObject.connect(process_ptr, pyqtSignal(self, name="closeEmitApp()"), process_ptr, pyqtSlot(self, name="close()")) # process_ptr.start("calc.exe", []) # self.createWindowContainer() program = "calc.exe" arguments = [] layout = QVBoxLayout() myProcess = QProcess(self) myProcess.setProgram(program) myProcess.setArguments(arguments) # myProcess. self.show() window = QWindow.fromWinId(self.winId()) container = self.createWindowContainer(window) # container. container.show() myProcess.setParent(window) myProcess.start() pid = myProcess.pid() print("PID:",int(pid)) LPWinProcInfo = ctypes.POINTER(WinProcInfo) lp = ctypes.cast(int(myProcess.pid()), LPWinProcInfo) print(lp.contents.dwProcessID) win32w = QWindow.fromWinId(pid) win32w.setFlags(Qt.FramelessWindowHint) widg = QWidget.createWindowContainer(win32w) # widget. #widget.setW layout.addWidget(widg) self.setLayout(layout) myProcess.waitForFinished()
def __init__(self,parent): QToolBar.__init__(self) #aaa=self.readStyleSheet(os.path.join(get_css_path(),"menu.css")) #aaa=str(aaa,'utf-8') #self.setStyleSheet(aaa) self.setToolButtonStyle( Qt.ToolButtonTextBesideIcon) self.setOrientation(Qt.Vertical) #self.setWindowFlags(Qt.FramelessWindowHint|Qt.WindowStaysOnTopHint|Qt.WindowStaysOnTopHint) self.setIconSize(QSize(42, 42)) self.configure_configwindow = QAction(QIcon_load("help"), _("Help window"), self) self.addAction(self.configure_configwindow) self.configure_configwindow = QAction(QIcon_load("help"), _("Manual"), self) self.addAction(self.configure_configwindow) self.configure_configwindow = QAction(QIcon_load("help"), _("License"), self) self.addAction(self.configure_configwindow) self.configure_configwindow = QAction(QIcon_load("help"), _("Youtube"), self) self.addAction(self.configure_configwindow) self.configure_configwindow = QAction(QIcon_load("help"), _("Citing the model"), self) self.addAction(self.configure_configwindow) self.configure_configwindow = QAction(QIcon_load("help"), _("About"), self) self.addAction(self.configure_configwindow) l=self.layout() for i in range(0,l.count()): l.itemAt(i).setAlignment(Qt.AlignLeft) self.installEventFilter(self) self.setWindowFlags(Qt.Popup) self.move(self.mapFromGlobal(QCursor.pos()))
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))