import sys
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5 import uic
from collections import deque
import time
import threading
import os
import pyttsx3
import pygame
class TimerWindowShow(QWidget):
showSignal = pyqtSignal(QWidget)
subsubsub_window_signal = pyqtSignal() # 定义一个信号
def __init__(self,total_seconds=None,ShowData=None,mode=None,event_listener=None,getdatalists=None,TheTimerId='NULL',lcdsetStyleSheet=None):
super().__init__()
# loader = uic.loadUi
print('get:',getdatalists)
self.getdatalists = getdatalists
self.TheTimerId=TheTimerId
self.event_listener = event_listener
self.total_seconds = total_seconds
self.currentSeconds=self.total_seconds
self.mode=mode
self.ShowData = ShowData
self.lcdsetStyleSheet=lcdsetStyleSheet
self.ui = uic.loadUi(r'..\ui\\TimerWindowsShow.ui')
self.ui._startPos = None
self.ui._endPos = None
self.ui._tracking = False
self.hidden=False
self.screen_width = QDesktopWidget().screenGeometry().width()
print('screen_width:',self.screen_width)
self.originWindowWidth=self.ui.width()
self.originWindowHeight=self.ui.height()
# 在 self.ui 上添加右键菜单
self.ui.setContextMenuPolicy(3) # 设置右键菜单策略为 CustomContextMenu
self.ui.customContextMenuRequested.connect(self.showContextMenu)
# self.ui.resize(240, 100)
# # 窗体置顶(窗体置顶,仅仅为了方便测试),去边框
# self.ui.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint)
# 设置窗口可缩放
self.ui.setWindowFlags(Qt.WindowStaysOnTopHint)
self.ui.setWindowFlag(Qt.FramelessWindowHint, True) # 移除无边框窗口标志
# self.ui.setWindowFlag(Qt.WindowMinMaxButtonsHint, True) # 显示最小化和最大化按钮
#窗体透明,控件不透明
self.setAttribute(Qt.WA_TranslucentBackground)
self.lcdNumber = self.ui.findChild(QLCDNumber)
self.lcdNumber.setStyleSheet(self.lcdsetStyleSheet)
# print(self.lcdNumber)
self.ShowImfornation = self.ui.findChild(QTextEdit, 'ShowData')
self.ShowImfornation.setCursorWidth(0) # 隐藏光标
self.updateDisplay()
self.UpdataShowData()
self.InitPushButton()
if self.getdatalists is not None:
self.dataNoneFlag=True
self.getdatalistsHand(self.getdatalists)
else:
self.dataNoneFlag=False
if mode == 'OtherMode':
self.OtherMode_Changeui()
self.ui.show()
# 安装事件过滤器
self.ui.installEventFilter(self)
def on_event_TimerWork(self):
self.TimerWork_ready()
print("TimerWork Runing")
def on_event_TimerStop(self):
self.TimerStop()
print("TimerStopped")
def on_event_CloseUi(self):
# print("隐藏TimerShow")
# self.ui.hide()
self.ui.resize(self.originWindowWidth, self.originWindowHeight)
x=QApplication.desktop().screenGeometry().width()//2-self.originWindowWidth//2
y=QApplication.desktop().screenGeometry().height()//2-self.originWindowHeight//2
self.ui.move(x,y)
self.subsubsub_window_signal.emit() # 触发信号
# self.close()
def register_for_event(self):
self.event_listener.register_callback1(self.on_event_TimerWork)
self.event_listener.register_callback2(self.on_event_TimerStop)
self.event_listener.register_callback3(self.on_event_CloseUi)
def OtherMode_Changeui(self):
self.ShowImfornation.hide()
self.AddTimes.hide()
self.StartOrStopTimer.hide()
self.ui.resize(self.ui.width() // 2, self.ui.height() // 2)
# 获取屏幕的分辨率
screen_geometry = QApplication.desktop().screenGeometry()
# 计算窗口的新位置,右上角的坐标
new_x = screen_geometry.width() - self.ui.width()
new_y = 0
# 将窗口移动到新位置
self.ui.move(new_x, new_y)
self.startAnimation(self.screen_width - 10, self.ui.frameGeometry().topLeft().y(), 'hide', 'right',showtimes=1000)
self.hidden=True
def eventFilter(self, obj, event):
if obj == self.ui and event.type() == QEvent.MouseMove:
self.mouseMoveEvent(event)
return True
elif obj == self.ui and event.type() == QEvent.MouseButtonPress:
self.mousePressEvent(event)
return True
elif obj == self.ui and event.type() == QEvent.MouseButtonRelease:
self.mouseReleaseEvent(event)
return True
elif obj==self.ui and event.type() == QEvent.Enter:
self.enterEvent(event)
return True
elif obj==self.ui and event.type() == QEvent.Leave:
self.leaveEvent(event)
return True
return super().eventFilter(obj, event)
def enterEvent(self, event):
self.hide_or_show('show', event)
def leaveEvent(self, event):
self.hide_or_show('hide', event)
def hide_or_show(self, mode, event):
# 获取窗口左上角x,y
pos = self.ui.frameGeometry().topLeft()
if mode == 'show' and self.hidden:
# 窗口左上角x + 窗口宽度 大于屏幕宽度,从右侧滑出
if pos.x() + self.ui.width() >= self.screen_width:
# 需要留10在里边,否则边界跳动
self.startAnimation(self.screen_width - self.ui.width(), pos.y())
event.accept()
self.hidden = False
# 窗口左上角x 小于0, 从左侧滑出
elif pos.x() <= 0:
self.startAnimation(0, pos.y())
event.accept()
self.hidden = False
# 窗口左上角y 小于0, 从上方滑出
elif pos.y() <= 0:
self.startAnimation(pos.x(), 0)
event.accept()
self.hidden = False
elif mode == 'hide' and (not self.hidden):
if pos.x() + self.ui.width() >= self.screen_width:
# 留10在外面
self.startAnimation(self.screen_width - 10, pos.y(), mode, 'right')
event.accept()
self.hidden = True
elif pos.x() <= 0:
# 留10在外面
self.startAnimation(10 - self.ui.width(), pos.y(), mode, 'left')
event.accept()
self.hidden = True
elif pos.y() <= 0:
# 留10在外面
self.startAnimation(pos.x(), 10 - self.ui.height(), mode, 'up')
event.accept()
self.hidden = True
def startAnimation(self, x, y, mode='show', direction=None,showtimes=200):
animation = QPropertyAnimation(self.ui, b"geometry", self.ui)
# 滑出动画时长
animation.setDuration(showtimes)
# 隐藏时,只留10在外边,防止跨屏
# QRect限制其大小,防止跨屏
num = QApplication.desktop().screenCount()
if mode == 'hide':
if direction == 'right':
animation.setEndValue(QRect(x, y, 10, self.ui.height()))
elif direction == 'left':
# 多屏时采用不同的隐藏方法,防止跨屏
if num < 2:
animation.setEndValue(QRect(x, y, self.ui.width(), self.ui.height()))
else:
animation.setEndValue(QRect(0, y, 10, self.ui.height()))
else:
if num < 2:
animation.setEndValue(QRect(x, y, self.ui.width(), self.ui.height()))
else:
animation.setEndValue(QRect(x, 0, self.ui.width(), 10))
else:
animation.setEnd
没有合适的资源?快使用搜索试试~ 我知道了~
基于PyQt5开发的倒计时软件 支持对PowerPoint进行事件监听,浮游窗口显示,个性化设置等
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共30个文件
py:14个
ui:8个
pyc:6个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 34 浏览量
2023-11-22
17:19:42
上传
评论
收藏 2.14MB ZIP 举报
温馨提示
一个由PyQt5开发的软件,主打的是倒计时功能的多样化显示。对PowerPoint进行事件监听,浮游窗口显示,个性化设置等等一些乱七八糟的功能
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 30 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/73f60d327bca40ada2cffddafa9efc4e_shiyunzhe2021.jpg!1)
云哲-吉吉2021
- 粉丝: 3440
- 资源: 1129
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)