Python源码示例:PyQt5.QtCore.Qt.WindowStaysOnTopHint()
示例1
def __init__(self, parent=None):
super(DesktopLyric, self).__init__()
self.lyric = QString('Lyric Show.')
self.intervel = 0
self.maskRect = QRectF(0, 0, 0, 0)
self.maskWidth = 0
self.widthBlock = 0
self.t = QTimer()
self.screen = QApplication.desktop().availableGeometry()
self.setObjectName(_fromUtf8("Dialog"))
self.setWindowFlags(Qt.CustomizeWindowHint | Qt.FramelessWindowHint | Qt.Dialog | Qt.WindowStaysOnTopHint | Qt.Tool)
self.setMinimumHeight(65)
self.setAttribute(Qt.WA_TranslucentBackground)
self.handle = lyric_handle(self)
self.verticalLayout = QVBoxLayout(self)
self.verticalLayout.setSpacing(0)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
self.font = QFont(_fromUtf8('微软雅黑, verdana'), 50)
self.font.setPixelSize(50)
# QMetaObject.connectSlotsByName(self)
self.handle.lyricmoved.connect(self.newPos)
self.t.timeout.connect(self.changeMask)
示例2
def __init__(self):
super().__init__(parent=None)
self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint)
self.setAttribute(Qt.WA_TranslucentBackground)
self.c = Container(self)
self._layout = QVBoxLayout(self)
self._layout.setContentsMargins(0, 0, 0, 0)
self._layout.setSpacing(0)
self._layout.addWidget(self.c)
self._old_pos = None
QShortcut(QKeySequence.ZoomIn, self).activated.connect(self.zoomin)
QShortcut(QKeySequence.ZoomOut, self).activated.connect(self.zoomout)
QShortcut(QKeySequence('Ctrl+='), self).activated.connect(self.zoomin)
QShortcut(QKeySequence.Cancel, self).activated.connect(self.hide)
self.setToolTip('''
* 右键可以弹出设置菜单
* Ctrl+= 或者 Ctrl++ 可以增大字体
* Ctrl+- 可以减小字体
* 鼠标前进后退键可以播放前一首/下一首
''')
示例3
def __init__(self,):
super().__init__(parent=None)
self._widget = None
self._timer = QTimer(self)
self._old_pos = None
self._widget = None
self._size_grip = QSizeGrip(self)
self._timer.timeout.connect(self.__on_timeout)
# setup window layout
self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint)
self._size_grip.setFixedSize(20, 20)
self._layout = QVBoxLayout(self)
self._layout.setContentsMargins(0, 0, 0, 0)
self._layout.setSpacing(0)
self._layout.addWidget(self._size_grip)
self._layout.setAlignment(self._size_grip, Qt.AlignBottom | Qt.AlignRight)
self.setMouseTracking(True)
示例4
def auto_extract_clipboard(self):
if not self.watch_clipboard:
return
text = self.clipboard.text()
pat = r"(https?://(\w[-\w]*\.)?lanzou[six].com/[bi]?[a-z0-9]+)[^0-9a-z]*([a-z0-9]+)?"
for share_url, _, pwd in re.findall(pat, text):
if share_url and not self.get_shared_info_thread.isRunning():
self.line_share_url.setEnabled(False)
self.btn_extract.setEnabled(False)
txt = share_url + "提取码:" + pwd if pwd else share_url
self.line_share_url.setText(txt)
self.get_shared_info_thread.set_values(txt)
self.tabWidget.setCurrentIndex(0)
self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint) # 窗口最前
self.show()
self.setWindowFlags(Qt.WindowCloseButtonHint | Qt.WindowMinMaxButtonsHint) # 窗口恢复
self.show()
break
示例5
def onStart(self, index):
try:
editor = configs[index]["editor"]
if editor["windowStaysOnTop"] is True:
self.setWindowFlags(Qt.WindowStaysOnTopHint)
else:
pass
except Exception as err:
pass # log exception
self.font = QFont()
self.font.setFamily(self.editor["editorFont"])
self.font.setPointSize(self.editor["editorFontSize"])
self.tabSize = self.editor["TabWidth"]
示例6
def __init__(self, word):
super(NoMatch, self).__init__()
self.setWindowFlags(
Qt.Widget
| Qt.WindowCloseButtonHint
| Qt.WindowStaysOnTopHint
| Qt.FramelessWindowHint
)
self.layout = QHBoxLayout()
self.word = word
self.no_match = QLabel("No match found for word: {}".format(self.word))
self.ok_button = QPushButton("OK")
self.ok_button.setAutoDefault(True)
self.ok_button.clicked.connect(self.ok_pressed)
self.layout.addWidget(self.no_match)
self.layout.addWidget(self.ok_button)
self.setLayout(self.layout)
self.show()
示例7
def __init__(self, parent, movable=False):
super().__init__()
self.setWindowFlags(
Qt.Widget
| Qt.WindowCloseButtonHint
| Qt.WindowStaysOnTopHint
| Qt.FramelessWindowHint
)
self.movable = movable
self.layout = QVBoxLayout()
self.pressed = False
self.process = QProcess()
self.parent = parent
self.clicked = False
self.name = None
self.process.readyReadStandardError.connect(self.onReadyReadStandardError)
self.process.readyReadStandardOutput.connect(self.onReadyReadStandardOutput)
self.setLayout(self.layout)
self.setStyleSheet("QWidget {background-color:invisible;}")
self.add() # Add items to the layout
# self.showMaximized() # comment this if you want to embed this widget
示例8
def __init__(self, mainwin):
super(ConfDialog, self).__init__()
self._app = QApplication.instance() # 获取app实例
self.setWindowFlags(Qt.Tool | Qt.WindowStaysOnTopHint)
self.win = mainwin
self.leftList = QListWidget()
self.rightStack = QStackedWidget()
self.optionActions = {}
self.changedOptions = {}
self.initUI()
self.initConfOptions()
self.initOptionActions()
recentlist = self.win.config["file.recent"]
if recentlist:
self.win.recent.setList(recentlist)
self.alertChLang = False
示例9
def __init__(self, *args, **kwargs):
super(NotificationWindow, self).__init__(*args, **kwargs)
self.setSpacing(20)
self.setMinimumWidth(412)
self.setMaximumWidth(412)
QApplication.instance().setQuitOnLastWindowClosed(True)
# 隐藏任务栏,无边框,置顶等
self.setWindowFlags(self.windowFlags() | Qt.Tool |
Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)
# 去掉窗口边框
self.setFrameShape(self.NoFrame)
# 背景透明
self.viewport().setAutoFillBackground(False)
self.setAttribute(Qt.WA_TranslucentBackground, True)
# 不显示滚动条
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
# 获取屏幕高宽
rect = QApplication.instance().desktop().availableGeometry(self)
self.setMinimumHeight(rect.height())
self.setMaximumHeight(rect.height())
self.move(rect.width() - self.minimumWidth() - 18, 0)
示例10
def __init__(self, parent=None):
super(lyric_handle, self).__init__(parent)
self.timer = QTimer()
self.setObjectName(_fromUtf8("Dialog"))
self.setWindowFlags(Qt.CustomizeWindowHint | Qt.FramelessWindowHint | Qt.Dialog | Qt.WindowStaysOnTopHint | Qt.Tool)
self.setStyleSheet('QDialog { background: #2c7ec8; border: 0px solid black;}')
self.horiLayout = QHBoxLayout(self)
self.horiLayout.setSpacing(5)
self.horiLayout.setContentsMargins(0, 0, 0, 0)
self.horiLayout.setObjectName(_fromUtf8("horiLayout"))
self.handler = QLabel(self)
self.handler.setToolTip('Move Lyric')
self.handler.setPixmap(QPixmap(':/icons/handler.png'))
self.handler.setMouseTracking(True)
self.lockBt = PushButton2(self)
self.lockBt.setToolTip('Unlocked')
self.lockBt.loadPixmap(QPixmap(':/icons/unlock.png'))
self.hideBt = PushButton2(self)
self.hideBt.setToolTip('Hide Lyric')
self.hideBt.loadPixmap(QPixmap(':/icons/close.png').copy(48, 0, 16, 16))
self.lockBt.setCheckable(True)
self.horiLayout.addWidget(self.handler)
self.horiLayout.addWidget(self.lockBt)
self.horiLayout.addWidget(self.hideBt)
self.lockBt.clicked.connect(self.lockLyric)
self.hideBt.clicked.connect(self.hideLyric)
self.timer.timeout.connect(self.hide)
示例11
def __init__(self, parent=None):
super(FMoveableWidget, self).__init__(parent)
self.setAttribute(Qt.WA_TranslucentBackground, True)
self.setAttribute(Qt.WA_Hover, True)
self.setWindowFlags(Qt.SubWindow | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)
self.installEventFilter(self)
self.boderFlag = False
self.isSideClicked = False
self.isCusorLeftSide = False
self.isCusorRightSide = False
self.isCusorDownSide = False
示例12
def __init__(self, conf, defeat):
self.config = conf
super().__init__()
self.setWindowTitle(conf.get_text('victory'))
self.setFixedSize(QSize(640, 480))
self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.WindowTitleHint | Qt.FramelessWindowHint)
button = QPushButton(conf.get_text('close'), self)
button.setCheckable(True)
button.setFixedSize(QSize(640, 30))
button.move(0, 450)
# noinspection PyUnresolvedReferences
button.clicked.connect(self.close)
result_output = QTextEdit(self)
result_output.setReadOnly(True)
result_output.setFixedSize(QSize(640, 200))
result_output.move(0, 250)
result_output.setLineWrapMode(QTextEdit.NoWrap)
result_output.insertHtml(self.generate_result_text())
gview = QGraphicsView(self)
scene = QGraphicsScene()
if defeat:
img = conf.theme_selected.get_defeat_pixmap()
text = conf.get_text('defeat')
else:
img = conf.theme_selected.get_victory_pixmap()
text = conf.get_text('victory')
scene.addPixmap(img.scaled(QSize(640, 220)))
gview.move(0, 30)
gview.setScene(scene)
label_title = QLabel(self)
label_title.setText(text)
label_title.setFixedSize(QSize(640, 30))
label_title.setAlignment(Qt.AlignCenter)
label_title.setFont(self.get_font_title())
示例13
def stayOnTop(self):
self.setWindowFlags(self.windowFlags()^Qt.WindowStaysOnTopHint)
self.show()
示例14
def alwaysFrontFunc(self):
"""change window status
"""
if self.alwaysFront.isChecked():
# print("Front", self.windowFlags())
self.setWindowFlags(
self.windowFlags() | Qt.WindowStaysOnTopHint
) # always top
self.show()
else:
# print("Back", self.win.windowFlags())
self.setWindowFlags(Qt.Widget)
self.show()
示例15
def __init__(self, *args, **kwargs):
super(ScaleWindow, self).__init__(*args, **kwargs)
self.setWindowFlags(Qt.Tool | Qt.FramelessWindowHint |
Qt.WindowStaysOnTopHint)
self.setAttribute(Qt.WA_TranslucentBackground, True)
self.resize(1, 1)
self.move(1, 1)
self._image = None
示例16
def set_window_to_corner(self):
self.move(self.window_original_position.bottomRight())
# Set to 30% screen size
screen = getScreenGeometry()
self.resize(screen.width() * 0.7 / 2, screen.height() * 0.7 / 2)
self.hide_show_bar()
self.setWindowFlags(Qt.SplashScreen | Qt.WindowStaysOnTopHint)
self.show()
示例17
def set_window_to_corner(self):
self.move(self.window_original_position.bottomRight())
# Set to 30% screen size
screen = getScreenGeometry()
self.resize(screen.width() * 0.7 / 2, screen.height() * 0.7 / 2)
self.hide_show_bar()
self.setWindowFlags(Qt.SplashScreen | Qt.WindowStaysOnTopHint)
self.show()
示例18
def __init__(self, controller):
super().__init__()
self.controller = controller
self.setWindowTitle('GIS parameters')
self.setWindowFlags(Qt.WindowStaysOnTopHint)
layout = QGridLayout()
# choose the projection and change it
choose_projection = QLabel('Type of projection')
self.projection_list = QComboBox(self)
self.projection_list.addItems(Map.projections)
# choose the map/nodes ratio
ratio = QLabel('Size of a node on the map')
self.ratio_edit = QLineEdit('100')
self.ratio_edit.setMaximumWidth(120)
draw_map_button = QPushButton('Redraw map')
draw_map_button.clicked.connect(self.redraw_map)
# position in the grid
layout.addWidget(choose_projection, 0, 0, 1, 1)
layout.addWidget(self.projection_list, 0, 1, 1, 1)
layout.addWidget(ratio, 1, 0, 1, 1)
layout.addWidget(self.ratio_edit, 1, 1, 1, 1)
layout.addWidget(draw_map_button, 2, 0, 1, 2)
self.setLayout(layout)
示例19
def show_plot(self):
self.closePrev()
self.plotter = PlotFeatures(self.skeletons_file,
self.timeseries_data,
self.traj_worm_index_grouped,
self.time_units,
self.xy_units,
self.fps,
parent = self)
self.plotter.setWindowFlags(self.plotter.windowFlags() | Qt.WindowStaysOnTopHint)
self.plotter.show()
self.update_plot()
示例20
def __init__(self, text):
if QApplication.instance() is None:
self.dialog = None
print(text)
else:
self.dialog = QProgressDialog(text, 'Cancel', 0, 100)
self.dialog.setWindowFlags(Qt.WindowStaysOnTopHint)
self.dialog.show()
示例21
def __init__(self):
super(Splash, self).__init__(QPixmap(os.path.join(bs.settings.gfx_path, 'splash.gif')), Qt.WindowStaysOnTopHint)
示例22
def __init__(self, picfile):
pixmap = QPixmap(picfile)
# , Qt.WindowStaysOnTopHint)
super(SplashScreen, self).__init__(pixmap)
# self.setMask(splash_pix.mask())
# self.raise_()
self.labelAlignment = int(Qt.AlignBottom | Qt.AlignHCenter | Qt.AlignAbsolute)
self.show()
QApplication.flush()
示例23
def main():
app = QApplication(sys.argv)
app.setStyle('cleanlooks')
app.setApplicationName("Linguistica")
# Get screen resolution
# Why do we need to know screen resolution?
# Because this information is useful for setting the size of particular
# widgets, e.g., the webview for visualizing the word neighbor manifold
# (the bigger the webview size, the better it is for visualization!)
resolution = app.desktop().screenGeometry()
screen_width = resolution.width()
screen_height = resolution.height()
# create and display splash screen
splash_image_path = os.path.join(os.path.dirname(__file__),
'lxa_splash_screen.png')
splash_image = QPixmap(splash_image_path)
splash_screen = QSplashScreen(splash_image, Qt.WindowStaysOnTopHint)
splash_screen.setMask(splash_image.mask())
splash_screen.show()
app.processEvents()
time.sleep(2)
# launch graphical user interface
form = MainWindow(screen_height, screen_width, __version__)
form.show()
splash_screen.finish(form)
app.exec_()
示例24
def _init(self):
# 隐藏任务栏|去掉边框|顶层显示
self.setWindowFlags(Qt.Tool | Qt.X11BypassWindowManagerHint |
Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)
# 关闭按钮事件
self.buttonClose.clicked.connect(self.onClose)
# 点击查看按钮
self.buttonView.clicked.connect(self.onView)
# 是否在显示标志
self.isShow = True
# 超时
self._timeouted = False
# 桌面
self._desktop = QApplication.instance().desktop()
# 窗口初始开始位置
self._startPos = QPoint(
self._desktop.screenGeometry().width() - self.width() - 5,
self._desktop.screenGeometry().height()
)
# 窗口弹出结束位置
self._endPos = QPoint(
self._desktop.screenGeometry().width() - self.width() - 5,
self._desktop.availableGeometry().height() - self.height() - 5
)
# 初始化位置到右下角
self.move(self._startPos)
# 动画
self.animation = QPropertyAnimation(self, b"pos")
self.animation.finished.connect(self.onAnimationEnd)
self.animation.setDuration(1000) # 1s
# 弹回定时器
self._timer = QTimer(self, timeout=self.closeAnimation)
示例25
def __init__(self, *args, **kwargs):
super(FrameWidget, self).__init__(*args, **kwargs)
self.setWindowFlags(Qt.Tool | Qt.FramelessWindowHint |
Qt.WindowStaysOnTopHint)
self.setAttribute(Qt.WA_TranslucentBackground, True)
self.showFullScreen() # 全屏
self._rect = QRect() # 被探测的窗口的矩形位置
示例26
def pin(self, is_true):
if is_true:
self.setWindowFlags(self.windowFlags() | Qt.WindowStaysOnTopHint)
else:
self.setWindowFlags(self.windowFlags() & ~Qt.WindowStaysOnTopHint)
self.show()
示例27
def __init__(self):
"""Initialize the window."""
super().__init__()
self.setupUi(self)
self.setWindowFlags(
# Qt.Window |
Qt.CustomizeWindowHint |
Qt.WindowTitleHint |
Qt.WindowCloseButtonHint |
Qt.WindowStaysOnTopHint
)
self._no_internet_msg = pop_up(self, title=Messages.NO_CONNECTION,
text=Messages.NO_CONNECTION_MSG,
connection=self.close)
self._bad_db_download_msg = pop_up(self, title=Messages.BAD_DOWNLOAD,
text=Messages.BAD_DOWNLOAD_MSG,
connection=self.close)
self._slow_conn_msg = pop_up(self, title=Messages.SLOW_CONN,
text=Messages.SLOW_CONN_MSG,
connection=self.close)
self._download_thread = DownloadThread()
self._download_thread.finished.connect(self._wait_close)
self._download_thread.progress.connect(self._display_progress)
self._download_thread.speed_progress.connect(self._display_speed)
self.closed.connect(self._download_thread.set_exit)
self.cancel_btn.clicked.connect(self._terminate_process)
self._size = 0
self.target = None
示例28
def __init__(self):
super().__init__()
# self.setWindowFlags(Qt.WindowStaysOnTopHint)
hbox = QVBoxLayout(self)
self.label = QLabel()
self.label.setText("Check behaviors excluded by")
hbox.addWidget(self.label)
self.twExclusions = QTableWidget()
self.twExclusions.setSelectionBehavior(QAbstractItemView.SelectRows)
self.twExclusions.setAlternatingRowColors(True)
self.twExclusions.setEditTriggers(QAbstractItemView.NoEditTriggers)
hbox.addWidget(self.twExclusions)
hbox2 = QHBoxLayout()
spacer_item = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
hbox2.addItem(spacer_item)
self.pb_select_all = QPushButton("Check all")
self.pb_select_all.clicked.connect(lambda: self.pb_cb_selection("select"))
hbox2.addWidget(self.pb_select_all)
self.pb_unselect_all = QPushButton("Uncheck all")
self.pb_unselect_all.clicked.connect(lambda: self.pb_cb_selection("unselect"))
hbox2.addWidget(self.pb_unselect_all)
self.pb_revert_selection = QPushButton("Revert check")
self.pb_revert_selection.clicked.connect(lambda: self.pb_cb_selection("revert"))
hbox2.addWidget(self.pb_revert_selection)
self.pb_check_selected = QPushButton("Check selected")
self.pb_check_selected.clicked.connect(lambda: self.pb_selected(True))
hbox2.addWidget(self.pb_check_selected)
self.pb_uncheck_selected = QPushButton("Uncheck selected")
self.pb_uncheck_selected.clicked.connect(lambda: self.pb_selected(False))
hbox2.addWidget(self.pb_uncheck_selected)
self.pbCancel = QPushButton("Cancel")
self.pbCancel.clicked.connect(self.reject)
hbox2.addWidget(self.pbCancel)
self.pbOK = QPushButton("OK", clicked=self.accept)
'''self.pbOK.clicked.connect(self.accept)'''
hbox2.addWidget(self.pbOK)
hbox.addLayout(hbox2)
self.setLayout(hbox)
self.setWindowTitle("Behaviors exclusion matrix")
self.setGeometry(100, 100, 600, 400)