-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pref&fix&move] 优化休息一下的时间显示并将其移出
[实验性工具]
分类 & 更正自动打包py文件的路径 (#74)
* pref: 优化时间显示 Need: 如果测试通过,请将该工具移出实验性分类。 * fix: 修复路径问题 Issue #46 * 🎁 应用建议 Co-authored-by: Luna-Grace <842551475@qq.com> Co-authored-by: 鸭鸭「カモ」 <Yzcbs123@163.com> * pref&fix: 修复意外的.0 * fix: 移除多余库 * move: 将休息一下工具移出[实验性工具]分类 Need: 更新文档 @fjwxzde set --------- Co-authored-by: Luna-Grace <842551475@qq.com>
- Loading branch information
1 parent
d37caee
commit e43332f
Showing
11 changed files
with
73 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import os | ||
import sys | ||
import time | ||
import configparser | ||
from plyer import notification | ||
|
||
# READ config.ini file | ||
script_dir = os.path.dirname(os.path.abspath(sys.argv[0])) | ||
config_file_path = os.path.join(script_dir, "config.ini") | ||
config = configparser.ConfigParser() | ||
config.read(config_file_path) | ||
total_seconds = config.getint('set', 'time_s') | ||
|
||
if total_seconds <= 0: | ||
print(f"✕ 设置的时间必须为正整数") | ||
sys.exit(1) | ||
# 转单位 | ||
# int 与 整除(//) 都是向0取整 | ||
|
||
if total_seconds >= 3600: | ||
if total_seconds % 3600 == 0: | ||
time_h = total_seconds // 3600 | ||
text = f"{time_h} 小时" | ||
elif total_seconds % 1800 == 0: | ||
time_h = (total_seconds - 1800) // 3600 # 计算一共几个完整小时 | ||
text = f"{time_h}个半 小时" | ||
elif total_seconds % 60 == 0: | ||
time_h = total_seconds // 3600 | ||
time_m = (total_seconds % 3600) // 60 | ||
text = f"{time_h}小时 {time_m}分钟" | ||
elif total_seconds % 3600 >= 60: | ||
time_h = total_seconds // 3600 | ||
time_m = (total_seconds % 3600) // 60 | ||
time_s = total_seconds % 60 | ||
text = f"{time_h}小时 {time_m}分钟 {time_s}秒" | ||
else: | ||
time_h = total_seconds // 3600 | ||
time_s = total_seconds % 3600 | ||
text = f"{time_h}小时 {time_s}秒" | ||
elif total_seconds == 1800: | ||
text = "半小时" | ||
elif total_seconds >= 60: | ||
if total_seconds % 60 == 0: | ||
text = f"{total_seconds // 60} 分钟" | ||
else: | ||
time_s = total_seconds % 60 | ||
text = f"{total_seconds // 60} 分钟 {time_s} 秒" | ||
else: | ||
text = f"{total_seconds} 秒" | ||
|
||
while total_seconds >= 0: | ||
time.sleep(1) | ||
total_seconds -= 1 | ||
|
||
# at end time | ||
notification.notify( | ||
title='休息一下吧!', | ||
message=f'已经使用设备超过 {text} 了,休息一下吧!\n', | ||
timeout=10 | ||
) |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters