xubo пре 1 година
родитељ
комит
2cd201f5b7
1 измењених фајлова са 30 додато и 4 уклоњено
  1. 30 4
      main.py

+ 30 - 4
main.py

@@ -1,6 +1,6 @@
 import sys
 from PyQt5.QtCore import Qt, QUrl, QDateTime
-from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QFileDialog, QMessageBox, QDateTimeEdit
+from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QFileDialog, QMessageBox, QDateTimeEdit, QPushButton
 from PyQt5.QtGui import QDesktopServices
 from litter_helper import Ui_menu  # 确保这个导入路径是正确的
 
@@ -29,8 +29,11 @@ class MainWindow(QMainWindow, Ui_menu):
         # 设置标签的文本为传递的参数
         # self.label.setText(f"参数1: {self.param1}, 参数2: {self.param2}")
 
-        # 连接按钮点击事件到槽函数
-        self.startPushButton.clicked.connect(self.on_button_click)
+        # 开始执行
+        self.startPushButton.clicked.connect(self.on_start_button_click)
+
+        # 终止执行
+        self.endPushButton.clicked.connect(self.on_stop_button_click)
 
         # 编辑账号
         # 获取 QLabel 控件并替换为 ClickableLabel
@@ -70,6 +73,11 @@ class MainWindow(QMainWindow, Ui_menu):
             # 设置当前时间
             self.endDateTimeEdit.setDateTime(QDateTime.currentDateTime())
 
+        # 连接 watchPushButton 点击事件到槽函数
+        self.watchPushButton = self.findChild(QPushButton, "watchPushButton")
+        if self.watchPushButton:
+            self.watchPushButton.clicked.connect(self.on_watch_button_click)
+
     def on_label_click(self):
         options = QFileDialog.Options()
         file_name, _ = QFileDialog.getOpenFileName(self, "Open Text File", "", "Text Files (*.txt);;All Files (*)",
@@ -80,7 +88,7 @@ class MainWindow(QMainWindow, Ui_menu):
             except Exception as e:
                 QMessageBox.critical(self, "Error", f"Could not open file: {e}")
 
-    def on_button_click(self):
+    def on_start_button_click(self):
         # 在按钮点击时执行的操作
         print(f"按钮被点击了!参数1: {self.param1}, 参数2: {self.param2}")
 
@@ -94,10 +102,28 @@ class MainWindow(QMainWindow, Ui_menu):
             date_time_value = self.endDateTimeEdit.dateTime()
             print(f"选中的日期和时间: {date_time_value.toString('yyyy-MM-dd HH:mm:ss')}")
 
+        # 获取并发数
+        if self.concurrencyLineEdit:
+            print(f"并发数为: {self.concurrencyLineEdit.text()}")
+
+    # 终止执行
+    def on_stop_button_click(self):
+        print(f"终止执行! 目标网址: {self.urlLineEdit.text()}")
+
     def edit_accounts(self):
         # 编辑账号
         print(f"编辑账号: {self.accountsLabel.show()}")
 
+    def on_watch_button_click(self):
+        # 获取项目当前路径
+        current_path = sys.path[0]
+        # 拼接 txt 文件路径
+        file_path = f"{current_path}/results/2024-05-27.txt"
+        try:
+            QDesktopServices.openUrl(QUrl.fromLocalFile(file_path))
+        except Exception as e:
+            QMessageBox.critical(self, "Error", f"Could not open file: {e}")
+
 
 if __name__ == "__main__":
     app = QApplication(sys.argv)