python+pyqt实现右下角弹出框


Posted in Python onOctober 26, 2017

本文实例为大家分享了pyqt实现右下角弹出框的具体代码,供大家参考,具体内容如下

构造函数中:

self.desktop=QDesktopWidget() 
self.move((self.desktop.availableGeometry().width()-self.width()),self.desktop.availableGeometry().height()) #初始化位置到右下角 
self.showAnimation()
#弹出动画 
def showAnimation(self): 
  #显示弹出框动画 
  self.animation=QPropertyAnimation(self,"pos") 
  self.animation.setDuration(1000) 
  self.animation.setStartValue(QPoint(self.x(),self.y())) 
  self.animation.setEndValue(QPoint((self.desktop.availableGeometry().width()-self.width()),(self.desktop.availableGeometry().height()-self.height()+self.SHADOW_WIDTH))) 
  self.animation.start() 
 
  #设置弹出框1秒弹出,然后渐隐 
  self.remainTimer=QTimer() 
  self.connect(self.remainTimer,SIGNAL("timeout()"),self,SLOT("closeAnimation()")) 
  self.remainTimer.start(10000) #定时器10秒 
#关闭动画 
@pyqtSlot() 
def closeAnimation(self): 
  #清除Timer和信号槽 
  self.remainTimer.stop() 
  self.disconnect(self.remainTimer,SIGNAL("timeout()"),self,SLOT("closeAnimation()")) 
  self.remainTimer.deleteLater() 
  self.remainTimer=None 
  #弹出框渐隐 
  self.animation =QPropertyAnimation(self,"windowOpacity") 
  self.animation.setDuration(1000) 
  self.animation.setStartValue(1) 
  self.animation.setEndValue(0) 
  self.animation.start() 
  #动画完成后清理 
  self.connect(self.animation,SIGNAL("finished()"),self,SLOT("clearAll()")) 
 
#清理及退出 
@pyqtSlot() 
def clearAll(self): 
  self.disconnect(self.animation,SIGNAL("finished()"),self,SLOT("clearAll()")) 
  sys.exit()    #退出

或者直接: self.connect(self.animation,SIGNAL("finished()"),self,SLOT("close()"))

效果如下:

python+pyqt实现右下角弹出框

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持三水点靠木。

Python 相关文章推荐
浅析Python 中整型对象存储的位置
May 16 Python
Python快速从注释生成文档的方法
Dec 26 Python
python 字典修改键(key)的几种方法
Aug 10 Python
pandas读取csv文件,分隔符参数sep的实例
Dec 12 Python
面向对象学习之pygame坦克大战
Sep 11 Python
python读取ini配置的类封装代码实例
Jan 08 Python
Python实现CAN报文转换工具教程
May 05 Python
Python键鼠操作自动化库PyAutoGUI简介(小结)
May 17 Python
浅谈Keras参数 input_shape、input_dim和input_length用法
Jun 29 Python
Python3以GitHub为例来实现模拟登录和爬取的实例讲解
Jul 30 Python
Pytorch中Softmax和LogSoftmax的使用详解
Jun 05 Python
Python初识逻辑与if语句及用法大全
Aug 07 Python
python中模块的__all__属性详解
Oct 26 #Python
Python内建函数之raw_input()与input()代码解析
Oct 26 #Python
python分布式环境下的限流器的示例
Oct 26 #Python
Python Nose框架编写测试用例方法
Oct 26 #Python
Python面向对象编程基础解析(二)
Oct 26 #Python
Python面向对象编程基础解析(一)
Oct 26 #Python
获取Django项目的全部url方法详解
Oct 26 #Python
You might like
ThinkPHP查询语句与关联查询用法实例
2014/11/01 PHP
thinkphp 框架数据库切换实现方法分析
2020/05/18 PHP
js/jQuery对象互转(快速操作dom元素)
2013/02/04 Javascript
javascript数组去重方法终极总结
2014/06/05 Javascript
jQuery中innerHeight()方法用法实例
2015/01/19 Javascript
基于JavaScript Array数组方法(新手必看篇)
2016/08/20 Javascript
Angular2入门教程之模块和组件详解
2017/05/28 Javascript
layui前端框架之table表数据的刷新方法
2018/08/17 Javascript
vue element-ui读取pdf文件的方法
2019/11/26 Javascript
[03:59]第二届DOTA2亚洲邀请赛选手传记-VGJ.rOtk
2017/04/03 DOTA
[05:03]2018DOTA2亚洲邀请赛主赛事首日回顾
2018/04/04 DOTA
python使用百度翻译进行中翻英示例
2014/04/14 Python
简析Python的闭包和装饰器
2016/02/26 Python
Python3中的最大整数和最大浮点数实例
2019/07/09 Python
python中struct模块之字节型数据的处理方法
2019/08/27 Python
Python argparse模块应用实例解析
2019/11/15 Python
基于Python中isfile函数和isdir函数使用详解
2019/11/29 Python
40个你可能不知道的Python技巧附代码
2020/01/29 Python
python词云库wordcloud的使用方法与实例详解
2020/02/17 Python
PyCharm永久激活方式(推荐)
2020/09/22 Python
Python Serial串口基本操作(收发数据)
2020/11/06 Python
详解numpy1.19.4与python3.9版本冲突解决
2020/12/15 Python
CSS3中Color的一些特性介绍
2012/05/27 HTML / CSS
HTML5全屏(Fullscreen)API详细介绍
2015/04/24 HTML / CSS
Canvas与图片压缩的示例代码
2017/11/28 HTML / CSS
适合各种场合的美食礼品:Harry & David
2016/08/03 全球购物
美国环保婴儿用品公司:The Honest Company
2017/11/23 全球购物
Speedo速比涛中国官方网站:全球领先泳装运动品牌
2018/04/24 全球购物
英国现代市场:ARKET
2019/04/10 全球购物
杭州-飞时达软件有限公司.net笔面试
2012/04/28 面试题
EJB的角色和三个对象
2015/12/31 面试题
大学四年个人的自我评价
2014/02/26 职场文书
机关干部个人对照检查材料思想汇报
2014/09/28 职场文书
党支部工作总结2015
2015/04/01 职场文书
三严三实学习心得体会(精选N篇)
2016/01/05 职场文书
HTML实现仿Windows桌面主题特效的实现
2022/06/28 HTML / CSS