xiaom1128 发表于 2025-3-17 10:14

美化版 关机重起V2.0

不废话直接上图:

自用2年无BUG


下载地址:

https://wwpy.lanzoue.com/iEazA2qt57te
密码:e3ym

liuyang207 发表于 2025-4-7 15:56

这种小功能的软件,用deepseek一句话就生成好了。只是这破python打包出来有点大,可能是我要它把界面整得漂亮点的原因。

https://www.alipan.com/s/31q1zV46Wza

import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QVBoxLayout, QWidget, QLabel, QTimeEdit, QMessageBox
from PyQt5.QtCore import QTime, QTimer
import os
import subprocess

class SystemControlTool(QMainWindow):
    def __init__(self):
      super().__init__()
      self.setWindowTitle("系统控制工具")
      self.setGeometry(100, 100, 300, 400)
      self.setStyleSheet("""
            QMainWindow {
                background-color: #2c3e50;
                color: #ecf0f1;
            }
            QPushButton {
                background-color: #3498db;
                color: white;
                border: none;
                padding: 10px;
                font-size: 16px;
                border-radius: 5px;
                min-width: 200px;
            }
            QPushButton:hover {
                background-color: #2980b9;
            }
            QTimeEdit {
                background-color: #34495e;
                color: #ecf0f1;
                border: 1px solid #7f8c8d;
                padding: 5px;
                border-radius: 3px;
            }
            QLabel {
                font-size: 14px;
                margin-bottom: 5px;
            }
      """)

      self.initUI()

    def initUI(self):
      central_widget = QWidget()
      self.setCentralWidget(central_widget)
      layout = QVBoxLayout()

      # 关机按钮
      shutdown_btn = QPushButton("关机")
      shutdown_btn.clicked.connect(self.shutdown)
      layout.addWidget(shutdown_btn)

      # 重启按钮
      restart_btn = QPushButton("重启")
      restart_btn.clicked.connect(self.restart)
      layout.addWidget(restart_btn)

      # 休眠按钮
      sleep_btn = QPushButton("休眠")
      sleep_btn.clicked.connect(self.sleep)
      layout.addWidget(sleep_btn)

      # 定时关机
      layout.addWidget(QLabel("定时关机:"))
      self.time_edit = QTimeEdit()
      self.time_edit.setDisplayFormat("HH:mm")
      self.time_edit.setTime(QTime.currentTime())
      layout.addWidget(self.time_edit)

      schedule_btn = QPushButton("设置定时关机")
      schedule_btn.clicked.connect(self.schedule_shutdown)
      layout.addWidget(schedule_btn)

      central_widget.setLayout(layout)

    def shutdown(self):
      reply = QMessageBox.question(self, '确认', '确定要关机吗?',
                                    QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
      if reply == QMessageBox.Yes:
            os.system("shutdown /s /t 1")

    def restart(self):
      reply = QMessageBox.question(self, '确认', '确定要重启吗?',
                                    QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
      if reply == QMessageBox.Yes:
            os.system("shutdown /r /t 1")

    def sleep(self):
      reply = QMessageBox.question(self, '确认', '确定要休眠吗?',
                                    QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
      if reply == QMessageBox.Yes:
            os.system("rundll32.exe powrprof.dll,SetSuspendState 0,1,0")

    def schedule_shutdown(self):
      current_time = QTime.currentTime()
      shutdown_time = self.time_edit.time()
      
      if shutdown_time <= current_time:
            QMessageBox.warning(self, '错误', '请设置一个未来的时间')
            return
            
      seconds = current_time.secsTo(shutdown_time)
      reply = QMessageBox.question(self, '确认',
                                    f'将在{shutdown_time.toString("HH:mm")}关机,确认吗?',
                                    QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
      if reply == QMessageBox.Yes:
            os.system(f"shutdown /s /t {seconds}")
            QMessageBox.information(self, '成功', f'已设置定时关机: {shutdown_time.toString("HH:mm")}')

if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = SystemControlTool()
    window.show()
    sys.exit(app.exec_())

xiaom1128 发表于 2025-3-19 16:39

之所以推出这个软件,本人是一名有时需要远程电脑桌面的作者,有好几次想重起和关机,发现有时远程界面操作不了,用命令又太烦。后发现了此简单明了之软件,所以独乐乐,不如众乐乐{:1_918:}

yueyegufeng 发表于 2025-3-17 19:36

我还以为是可以设定时间自动关机重启呢,如果跟手机一样就好了

hz123 发表于 2025-3-17 20:20

被火绒直接杀了

linlizi 发表于 2025-3-17 21:38

不是重启么

快车0326 发表于 2025-3-17 22:06

我想不出这到底有什么长处,这些功能不自带吗都是! 为什么要多此一举呢:lol

西门官人 发表于 2025-3-18 00:35

本帖最后由 西门官人 于 2025-3-17 22:37 编辑


这个软件挺奇怪的,不知道是杀了啥病毒,报毒之后,又可以正常打开了






https://cdn-fusion.imgcdn.store/i/2025/c1e1334b98c6a862.pnghttps://cdn-fusion.imgcdn.store/i/2025/52bf3fa21579929d.png

li683305 发表于 2025-3-18 07:39

再添加一个定时关机就好了{:1_918:}

cycloneblack 发表于 2025-3-18 09:08

yueyegufeng 发表于 2025-3-17 19:36
我还以为是可以设定时间自动关机重启呢,如果跟手机一样就好了

定时关机重启可以看一下这个软件:Wise Auto Shutdown,这个比较好用。

idnbil 发表于 2025-3-18 10:28

做的还可以,谢谢分享。

liangshushu 发表于 2025-3-18 12:02

谢谢分享
页: [1] 2 3
查看完整版本: 美化版 关机重起V2.0