下拉菜单

This commit is contained in:
625781186 2018-07-07 16:57:04 +08:00
commit 357f1c643b
8 changed files with 146 additions and 2 deletions

View file

@ -38,6 +38,7 @@ encoding//\u4EFFQQ\u8BBE\u7F6E\u9762\u677F/SettingUi.py=utf-8
encoding//\u4EFFQQ\u8BBE\u7F6E\u9762\u677F/Window.py=utf-8 encoding//\u4EFFQQ\u8BBE\u7F6E\u9762\u677F/Window.py=utf-8
encoding//\u5168\u5C40\u70ED\u952E/HotKey.py=utf-8 encoding//\u5168\u5C40\u70ED\u952E/HotKey.py=utf-8
encoding//\u5206\u5272\u7A97\u53E3\u7684\u5206\u5272\u6761\u91CD\u5199/Splitter.py=utf-8 encoding//\u5206\u5272\u7A97\u53E3\u7684\u5206\u5272\u6761\u91CD\u5199/Splitter.py=utf-8
encoding//\u52A8\u753B\u7279\u6548/\u6DE1\u5165\u6DE1\u51FA.py=utf-8
encoding//\u53F3\u4E0B\u89D2\u5F39\u51FA\u6846/WindowNotify.py=utf-8 encoding//\u53F3\u4E0B\u89D2\u5F39\u51FA\u6846/WindowNotify.py=utf-8
encoding//\u56FE\u7247\u52A0\u8F7D/LoadImage.py=utf-8 encoding//\u56FE\u7247\u52A0\u8F7D/LoadImage.py=utf-8
encoding//\u56FE\u7247\u52A0\u8F7D/res_rc.py=utf-8 encoding//\u56FE\u7247\u52A0\u8F7D/res_rc.py=utf-8
@ -58,6 +59,7 @@ encoding//\u68A6\u5E7B\u6811/DreamTree.py=utf-8
encoding//\u6C14\u6CE1\u63D0\u793A/BubbleTips.py=utf-8 encoding//\u6C14\u6CE1\u63D0\u793A/BubbleTips.py=utf-8
encoding//\u6D4F\u89C8\u5668\u83B7\u53D6Cookie/WebEngineView.py=utf-8 encoding//\u6D4F\u89C8\u5668\u83B7\u53D6Cookie/WebEngineView.py=utf-8
encoding//\u6D4F\u89C8\u5668\u83B7\u53D6Cookie/WebView.py=utf-8 encoding//\u6D4F\u89C8\u5668\u83B7\u53D6Cookie/WebView.py=utf-8
encoding//\u6D88\u606F\u5BF9\u8BDD\u6846\u5012\u8BA1\u65F6\u5173\u95ED/MessageBox.py=utf-8
encoding//\u754C\u9762\u7F8E\u5316/QFileSystemModel\u56FE\u6807/FileSystemModel.py=utf-8 encoding//\u754C\u9762\u7F8E\u5316/QFileSystemModel\u56FE\u6807/FileSystemModel.py=utf-8
encoding//\u754C\u9762\u7F8E\u5316/QLabel\u5706\u5F62\u5934\u50CF/CircleLabel.py=utf-8 encoding//\u754C\u9762\u7F8E\u5316/QLabel\u5706\u5F62\u5934\u50CF/CircleLabel.py=utf-8
encoding//\u754C\u9762\u7F8E\u5316/QMessageBox\u6837\u5F0F/\u65B9\u6848\u4E00/critical.py=utf-8 encoding//\u754C\u9762\u7F8E\u5316/QMessageBox\u6837\u5F0F/\u65B9\u6848\u4E00/critical.py=utf-8

View file

@ -42,9 +42,9 @@
- [1.29 数据库查询显示表格](数据库查询显示表格/) - [1.29 数据库查询显示表格](数据库查询显示表格/)
- [1.30 左侧选项卡](左侧选项卡/) - [1.30 左侧选项卡](左侧选项卡/)
- [1.40 探测窗口和放大截图](探测窗口和放大截图/) - [1.40 探测窗口和放大截图](探测窗口和放大截图/)
- 1.41 悬浮下拉菜单 - [1.41 消息对话框倒计时关闭](消息对话框倒计时关闭/)
- 1.42 悬浮下拉菜单
- [1. tableWidget形式](partner_625781186/5.hoverMenu) - [1. tableWidget形式](partner_625781186/5.hoverMenu)
### [2.QGraphicsView练习](QGraphicsView练习/) ### [2.QGraphicsView练习](QGraphicsView练习/)
- [2.1 世界地图](QGraphicsView练习/世界地图) - [2.1 世界地图](QGraphicsView练习/世界地图)
- [2.2 添加QWidget](QGraphicsView练习/添加QWidget.py) - [2.2 添加QWidget](QGraphicsView练习/添加QWidget.py)
@ -66,6 +66,7 @@
- [4.9 水波纹进度条](界面美化/水波纹进度条) - [4.9 水波纹进度条](界面美化/水波纹进度条)
- [4.10 QSlider美化](界面美化/QSlider美化) - [4.10 QSlider美化](界面美化/QSlider美化)
### [5.QML](partner_625781186/QML_QtQuick_PY) ### [5.QML](partner_625781186/QML_QtQuick_PY)
- [python_QML调用基础](partner_625781186/QML_QtQuick_PY/python_QML调用基础) - [python_QML调用基础](partner_625781186/QML_QtQuick_PY/python_QML调用基础)
- QWidget窗体中嵌入qml界面 - QWidget窗体中嵌入qml界面
@ -73,6 +74,10 @@
- [QQmlApplicationEngine之qml嵌入qtwidget_qt5.8以上](partner_625781186/QML_QtQuick_PY/QQmlApplicationEngine之qml嵌入qtwidget_qt5.8以上) - [QQmlApplicationEngine之qml嵌入qtwidget_qt5.8以上](partner_625781186/QML_QtQuick_PY/QQmlApplicationEngine之qml嵌入qtwidget_qt5.8以上)
### [5.动画特效](动画特效/)
- [5.1 淡入淡出](动画特效/淡入淡出.py)
>>>>>>> iron/master
# QQ群 # QQ群
- [PyQt & PySide](https://jq.qq.com/?_wv=1027&k=50LWvn9) - [PyQt & PySide](https://jq.qq.com/?_wv=1027&k=50LWvn9)
- [PyQt学习互助](https://jq.qq.com/?_wv=1027&k=5QVVEdF) - [PyQt学习互助](https://jq.qq.com/?_wv=1027&k=5QVVEdF)

7
动画特效/README.md Normal file
View file

@ -0,0 +1,7 @@
# 简单的动画特效
使用QPropertyAnimation属性类动画支持的属性有限
### 常见例子
- [1.1 淡入淡出](淡入淡出.py)<br/>
![截图](ScreenShot/1.gif)

Binary file not shown.

After

Width:  |  Height:  |  Size: 630 KiB

View file

@ -0,0 +1,61 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from PyQt5.QtCore import QPropertyAnimation
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QPushButton
# Created on 2018年6月14日
# author: Irony
# site: https://github.com/892768447
# email: 892768447@qq.com
# file: 动画特效.淡入淡出
# description:
__Author__ = """By: Irony
QQ: 892768447
Email: 892768447@qq.com"""
__Copyright__ = 'Copyright (c) 2018 Irony'
__Version__ = 1.0
class Window(QWidget):
def __init__(self, *args, **kwargs):
super(Window, self).__init__(*args, **kwargs)
self.resize(400, 400)
layout = QVBoxLayout(self)
layout.addWidget(QPushButton('退出', self, clicked=self.doClose))
# 窗口透明度动画类
self.animation = QPropertyAnimation(self, b'windowOpacity')
self.animation.setDuration(1000) # 持续时间1秒
# 执行淡入
self.doShow()
def doShow(self):
try:
self.animation.finished.disconnect(self.close)
except:
pass
self.animation.stop()
# 透明度范围从0逐渐增加到1
self.animation.setStartValue(0)
self.animation.setEndValue(1)
self.animation.start()
def doClose(self):
self.animation.stop()
self.animation.finished.connect(self.close) # 动画完成则关闭窗口
# 透明度范围从1逐渐减少到0
self.animation.setStartValue(1)
self.animation.setEndValue(0)
self.animation.start()
if __name__ == '__main__':
import sys
from PyQt5.QtWidgets import QApplication
app = QApplication(sys.argv)
w = Window()
w.show()
sys.exit(app.exec_())

View file

@ -0,0 +1,63 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on 2018年6月22日
@author: Irony
@site: https://github.com/892768447
@email: 892768447@qq.com
@file: MessageBox
@description:
"""
from random import randrange
from PyQt5.QtCore import QTimer
from PyQt5.QtWidgets import QMessageBox
__Author__ = """By: Irony
QQ: 892768447
Email: 892768447@qq.com"""
__Copyright__ = "Copyright (c) 2018 Irony"
__Version__ = "Version 1.0"
class MessageBox(QMessageBox):
def __init__(self, *args, count=5, time=1000, auto=False, **kwargs):
super(MessageBox, self).__init__(*args, **kwargs)
self._count = count
self._time = time
self._auto = auto # 是否自动关闭
assert count > 0 # 必须大于0
assert time >= 500 # 必须>=500毫秒
self.setStandardButtons(self.Close) # 关闭按钮
self.closeBtn = self.button(self.Close) # 获取关闭按钮
self.closeBtn.setText('关闭(%s)' % count)
self.closeBtn.setEnabled(False)
self._timer = QTimer(self, timeout=self.doCountDown)
self._timer.start(self._time)
print('是否自动关闭', auto)
def doCountDown(self):
self.closeBtn.setText('关闭(%s)' % self._count)
self._count -= 1
if self._count <= 0:
self.closeBtn.setText('关闭')
self.closeBtn.setEnabled(True)
self._timer.stop()
if self._auto: # 自动关闭
self.accept()
self.close()
if __name__ == '__main__':
import sys
from PyQt5.QtWidgets import QApplication, QPushButton
app = QApplication(sys.argv)
w = QPushButton('点击弹出对话框')
w.resize(200, 200)
w.show()
w.clicked.connect(lambda: MessageBox(
w, text='倒计时关闭对话框', auto=randrange(0, 2)).exec_())
sys.exit(app.exec_())

View file

@ -0,0 +1,6 @@
# 消息对话框倒计时关闭
通过继承QMessageBox实现倒计时关闭的对话框
# 截图
![截图1](ScreenShot/1.gif)

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 KiB