Python源码示例:PyQt5.QtCore.Qt.Tool()
示例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, 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
示例3
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)
示例4
def __init__(self, devices):
super().__init__()
self.setWindowFlags(Qt.Tool)
self.setMinimumSize(QSize(640, 480))
self.devices = devices
self.command = ""
vl = VLayout()
gbxDevice = GroupBoxV("Commands history for:")
gbDevice = QComboBox()
gbDevice.addItems([d.p['FriendlyName1'] for d in devices])
gbxDevice.addWidget(gbDevice)
self.lwCommands = QListWidget()
vl.addWidgets([gbxDevice, self.lwCommands, QLabel("Double-click a command to use it, ESC to close.")])
self.setLayout(vl)
gbDevice.currentIndexChanged.connect(self.load_history)
self.lwCommands.doubleClicked.connect(self.select_command)
示例5
def __init__(self, etree, style, pkmeter, parent=None):
PKWidget.__init__(self, etree, pkmeter, parent)
self.pkmeter = pkmeter
self.setStyleSheet(style)
self.setAttribute(Qt.WA_TranslucentBackground)
self.setWindowFlags(
Qt.Tool |
Qt.FramelessWindowHint |
Qt.WindowStaysOnBottomHint |
Qt.NoDropShadowWindowHint |
Qt.CustomizeWindowHint)
self.layout().setContentsMargins(0,0,0,0)
self.layout().setSpacing(0)
self._init_menu()
pkmixins.DraggableMixin.__init__(self)
示例6
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)
示例7
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
示例8
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)
示例9
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() # 被探测的窗口的矩形位置