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进行事件监听,浮游窗口显示,个性化设置等
共30个文件
py:14个
ui:8个
pyc:6个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 89 浏览量
2023-11-22
17:19:42
上传
评论
收藏 2.14MB ZIP 举报
温馨提示
一个由PyQt5开发的软件,主打的是倒计时功能的多样化显示。对PowerPoint进行事件监听,浮游窗口显示,个性化设置等等一些乱七八糟的功能
资源推荐
资源详情
资源评论
收起资源包目录
Ti-master.zip (30个子文件)
Ti-master
ui
mainWindows1.0.ui 8KB
image.png 2.09MB
untitled.ui 992B
ShowPPT.ui 1KB
TimerWindowsShow.ui 2KB
ShowFullWindo.ui 393B
DialogMisson.ui 1KB
MainWindows2.0v.ui 7KB
ShowFullWindow.ui 668B
code
OnlyShowBkAndTimer.py 3KB
test20.py 4B
Register.py 4KB
MainWindows1.0.py 2KB
ShowPPTWindow.py 860B
testfun.py 1KB
ShowPPT.py 5KB
EditMissonView.py 6KB
main_test.py 111B
MainWindows2v.py 16KB
register.bin 32B
functiontest.py 3KB
PersonalizeSet.py 4KB
ListViewWindows.py 147B
__pycache__
Register.cpython-39.pyc 4KB
functiontest.cpython-39.pyc 3KB
ShowPPT.cpython-39.pyc 6KB
EditMissonView.cpython-39.pyc 5KB
TimerWindowsShow.cpython-39.pyc 15KB
MainWindows2v.cpython-39.pyc 4KB
TimerWindowsShow.py 20KB
共 30 条
- 1
资源评论
云哲-吉吉2021
- 粉丝: 3440
- 资源: 1129
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功