|
|
# -*- coding: utf-8 -*- |
|
|
import pandas as pd |
|
|
from threading import Thread |
|
|
from PyQt5.QtWidgets import QApplication, QMainWindow,QMessageBox |
|
|
from print_setting_ui import Ui_MainWindow |
|
|
from PyQt5.QtGui import QFont |
|
|
from PySide2.QtCore import Signal,QObject |
|
|
from PyQt5.QtCore import QThread, pyqtSignal, QProcess |
|
|
import sys |
|
|
import os |
|
|
import warnings |
|
|
import time |
|
|
import time |
|
|
from PyQt5.QtWidgets import (QApplication, QWidget, QPushButton, QLabel, |
|
|
QVBoxLayout, QFileDialog, QMessageBox) |
|
|
from threading import Thread |
|
|
from print_factory_type_setting_obj_run import print_type_setting_obj |
|
|
|
|
|
warnings.filterwarnings('ignore') |
|
|
pd.set_option('display.width', None) |
|
|
|
|
|
|
|
|
class MySignals(QObject): |
|
|
text_print = Signal(str) |
|
|
update_table = Signal(str) |
|
|
|
|
|
|
|
|
class MyMainForm(QMainWindow, Ui_MainWindow): |
|
|
def __init__(self,parent=None): |
|
|
super(MyMainForm, self).__init__(parent) |
|
|
self.setupUi(self) |
|
|
self.folder_path = "" |
|
|
self.cache_path = "" |
|
|
self.pushButton.clicked.connect(self.on_select_folder) |
|
|
self.pushButton_2.clicked.connect(self.on_run_clicked) |
|
|
self.pushButton_3.clicked.connect(self.on_open_output_clicked) |
|
|
self.global_ms = MySignals() |
|
|
self.global_ms.text_print.connect(self.printToGui) |
|
|
|
|
|
def printToGui(self,text): |
|
|
n_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) |
|
|
self.textBrowser.append(n_time+" "+str(text)) |
|
|
|
|
|
def on_select_folder(self): |
|
|
folder = QFileDialog.getExistingDirectory(self, "选择文件夹") |
|
|
if folder: |
|
|
self.folder_path = folder |
|
|
#self.folder_path_label.setText(f"📂 当前选择文件夹: {folder}") |
|
|
#self.run_status_label.setText("") |
|
|
self.cache_path = folder + "_arrange" |
|
|
os.makedirs(self.cache_path, exist_ok=True) |
|
|
|
|
|
def on_run_clicked(self): |
|
|
|
|
|
def threadFunc1(): |
|
|
if not self.folder_path: |
|
|
#self.run_status_label.setText("❗请先选择一个文件夹再执行!") |
|
|
return |
|
|
|
|
|
# if hasattr(self, 'worker') and self.worker.isRunning(): |
|
|
# self.run_status_label.setText("⚠️ 正在执行中,请稍候...") |
|
|
# return |
|
|
#self.run_btn.setEnabled(False) |
|
|
#self.run_status_label.setText("🚀 程序正在运行,请稍候...") |
|
|
|
|
|
print_type_setting_obj( |
|
|
base_original_obj_dir=self.folder_path, |
|
|
cache_type_setting_dir=self.cache_path, |
|
|
show_chart=False |
|
|
) |
|
|
|
|
|
#self.run_status_label.setText("✅ 排版完成!") |
|
|
|
|
|
thread = Thread(target=threadFunc1) |
|
|
thread.start() |
|
|
|
|
|
def open_file_cross_platform(self, path): |
|
|
if not os.path.exists(path): |
|
|
print("路径不存在!") |
|
|
return |
|
|
if sys.platform.startswith('win'): |
|
|
os.startfile(path) |
|
|
elif sys.platform.startswith('darwin'): |
|
|
QProcess.startDetached("open", [path]) |
|
|
else: |
|
|
QProcess.startDetached("xdg-open", [path]) |
|
|
|
|
|
def on_open_output_clicked(self): |
|
|
output_path = os.path.join(self.cache_path, "print_compact_obj") |
|
|
if os.path.exists(output_path): |
|
|
self.open_file_cross_platform(output_path) |
|
|
else: |
|
|
self.run_status_label.setText("⚠️ 输出文件夹不存在!") |
|
|
|
|
|
|
|
|
def douyin_spider_go(self): |
|
|
"""下载抖音视频""" |
|
|
def threadFunc1(): |
|
|
print("开始下载") |
|
|
self.load_chrome_video() |
|
|
thread = Thread(target=threadFunc1) |
|
|
thread.start() |
|
|
#thread.run() |
|
|
|
|
|
def open_config_dir(self): |
|
|
"""打开文件夹""" |
|
|
def threadFunc1(): |
|
|
try: |
|
|
start_directory = os.path.join(self.dir_base) |
|
|
os.startfile(start_directory) |
|
|
except RecursionError: |
|
|
print("打开配置文件夹失败。") |
|
|
thread = Thread(target=threadFunc1) |
|
|
thread.start() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
#multiprocessing.freeze_support() |
|
|
app = QApplication(sys.argv) |
|
|
myWin = MyMainForm() |
|
|
myWin.show() |
|
|
sys.exit(app.exec_()) |
|
|
|
|
|
|
|
|
|