提交 35c67909 编写于 作者: 之一Yo's avatar 之一Yo

添加对话框的返回值

上级 2f3bf47f
......@@ -9,17 +9,16 @@
</p>
<p align="center">
<a style="text-decoration:none">
<img src="https://img.shields.io/badge/Python-3.6+-blue.svg?color=00B16A" alt="Python 3.6+"/>
<img src="https://img.shields.io/badge/Platform-Win32%20|%20Linux%20|%20macOS-blue?color=#4ec820" alt="Platform Win32 | Linux | macOS"/>
</a>
<a style="text-decoration:none">
<img src="https://img.shields.io/badge/PyQt-5.15.6-blue?color=00B16A" alt="PyQt 5.15.6"/>
<img src="https://static.pepy.tech/personalized-badge/pyqt-fluent-widgets?period=total&units=international_system&left_color=grey&right_color=brightgreen&left_text=Downloads" alt="Download"/>
</a>
<a style="text-decoration:none">
<img src="https://img.shields.io/badge/Platform-Win32%20|%20Linux%20|%20macOS-blue?color=00B16A" alt="Platform Win32 | Linux | macOS"/>
<img src="https://img.shields.io/badge/License-MIT-blue?color=#4ec820" alt="MIT"/>
</a>
</p>
......
......@@ -21,15 +21,15 @@
<p align="center">
<a style="text-decoration:none">
<img src="https://img.shields.io/badge/Python-3.6+-blue.svg?color=00B16A" alt="Python 3.6+"/>
<img src="https://img.shields.io/badge/Platform-Win32%20|%20Linux%20|%20macOS-blue?color=#4ec820" alt="Platform Win32 | Linux | macOS"/>
</a>
<a style="text-decoration:none">
<img src="https://img.shields.io/badge/PyQt-5.15.6-blue?color=00B16A" alt="PyQt 5.15.6"/>
<img src="https://static.pepy.tech/personalized-badge/pyqt-fluent-widgets?period=total&units=international_system&left_color=grey&right_color=brightgreen&left_text=Downloads" alt="Download"/>
</a>
<a style="text-decoration:none">
<img src="https://img.shields.io/badge/Platform-Win32%20|%20Linux%20|%20macOS-blue?color=00B16A" alt="Platform Win32 | Linux | macOS"/>
<img src="https://img.shields.io/badge/License-MIT-blue?color=#4ec820" alt="MIT"/>
</a>
</p>
......
......@@ -20,7 +20,10 @@ class Window(QWidget):
title = 'Are you sure you want to delete the folder?'
content = """If you delete the "Music" folder from the list, the folder will no longer appear in the list, but will not be deleted."""
w = Dialog(title, content, self)
w.exec()
if w.exec():
print('Yes button is pressed')
else:
print('Cancel button is pressed')
if __name__ == '__main__':
......
......@@ -20,7 +20,10 @@ class Window(QWidget):
title = 'Are you sure you want to delete the folder?'
content = """If you delete the "Music" folder from the list, the folder will no longer appear in the list, but will not be deleted."""
w = MessageDialog(title, content, self)
w.exec()
if w.exec():
print('Yes button is pressed')
else:
print('Cancel button is pressed')
if __name__ == '__main__':
......
"""
PyQt-Fluent-Widgets
===================
A library of fluent design widgets.
A fluent design widgets library based on PyQt5.
Documentation is available in the docstrings and
online at https://pyqt-fluent-widgets.readthedocs.io.
......@@ -10,7 +10,7 @@ online at https://pyqt-fluent-widgets.readthedocs.io.
:license: MIT, see LICENSE for more details.
"""
__version__ = "0.1.1"
__version__ = "0.1.6"
from .components import *
from .common import *
......
......@@ -64,11 +64,11 @@ class Dialog(FramelessDialog):
def __onCancelButtonClicked(self):
self.cancelSignal.emit()
self.deleteLater()
self.reject()
def __onYesButtonClicked(self):
self.yesSignal.emit()
self.deleteLater()
self.accept()
def __setQss(self):
""" 设置层叠样式 """
......
......@@ -50,11 +50,13 @@ class MessageDialog(MaskDialogBase):
def __onCancelButtonClicked(self):
self.cancelSignal.emit()
self.setResult(self.Rejected)
self.close()
def __onYesButtonClicked(self):
self.setEnabled(False)
self.yesSignal.emit()
self.setResult(self.Accepted)
self.close()
def __setQss(self):
......
# coding:utf-8
from PyQt5.QtCore import (Qt, QPropertyAnimation, pyqtProperty, QEasingCurve,
from PyQt5.QtCore import (QEvent, Qt, QPropertyAnimation, pyqtProperty, QEasingCurve,
QParallelAnimationGroup, QRect, QSize, QPoint)
from PyQt5.QtGui import QColor, QPixmap, QPainter
from PyQt5.QtWidgets import QFrame, QWidget, QAbstractButton, QApplication
......@@ -125,6 +125,7 @@ class ExpandSettingCard(QFrame):
setStyleSheet(self.card, 'expand_setting_card')
setStyleSheet(self, 'expand_setting_card')
self.card.installEventFilter(self)
self.aniGroup.finished.connect(self.__onAniFinished)
self.expandButton.clicked.connect(self.toggleExpand)
......@@ -170,27 +171,19 @@ class ExpandSettingCard(QFrame):
self.card.resize(self.width(), self.card.height())
self.view.resize(self.width(), self.view.height())
def enterEvent(self, e):
super().enterEvent(e)
self.expandButton.setHover(True)
def leaveEvent(self, e):
super().leaveEvent(e)
self.expandButton.setHover(False)
def mousePressEvent(self, e):
super().mousePressEvent(e)
if e.button() == Qt.LeftButton:
self.expandButton.setPressed(True)
def mouseReleaseEvent(self, e):
super().mouseReleaseEvent(e)
if e.button() == Qt.LeftButton:
self.expandButton.setPressed(False)
self.expandButton.click()
def sizeHint(self):
return self.size()
def eventFilter(self, obj, e):
if obj is self.card:
if e.type() == QEvent.Enter:
self.expandButton.setHover(True)
elif e.type()==QEvent.Leave:
self.expandButton.setHover(False)
elif e.type() == QEvent.MouseButtonPress and e.button() == Qt.LeftButton:
self.expandButton.setPressed(True)
elif e.type() == QEvent.MouseButtonRelease and e.button() == Qt.LeftButton:
self.expandButton.setPressed(False)
self.expandButton.click()
return super().eventFilter(obj, e)
def __onAniFinished(self):
""" expand animation finished slot """
......
......@@ -6,7 +6,7 @@ with open('README.md', encoding='utf-8') as f:
setuptools.setup(
name="PyQt-Fluent-Widgets",
version="0.1.5",
version="0.1.6",
keywords="pyqt fluent widgets",
author="zhiyiYo",
author_email="shokokawaii@outlook.com",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册