Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Japanese language only. When using this GUI program, you must also install the CUI program.
- # →https://pastebin.com/BkgbGbn7
- import sys
- import os
- import json
- import subprocess
- from PySide6.QtWidgets import (
- QApplication, QWidget, QVBoxLayout, QHBoxLayout, QPushButton,
- QLabel, QFileDialog, QProgressBar, QMessageBox
- )
- from PySide6.QtCore import Qt
- CONFIG_FILE = "gui_config.json"
- def load_config():
- if os.path.exists(CONFIG_FILE):
- with open(CONFIG_FILE, "r", encoding="utf-8") as f:
- return json.load(f)
- return {}
- def save_config(cfg):
- with open(CONFIG_FILE, "w", encoding="utf-8") as f:
- json.dump(cfg, f, ensure_ascii=False, indent=2)
- def detect_dark_mode():
- # 窓
- if sys.platform.startswith("win"):
- try:
- import winreg
- reg = winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER)
- key = winreg.OpenKey(reg, r"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize")
- val, _ = winreg.QueryValueEx(key, "AppsUseLightTheme")
- return val == 0
- except Exception:
- return False
- # 林檎
- elif sys.platform.startswith("darwin"):
- try:
- import subprocess
- out = subprocess.check_output(
- ["defaults", "read", "-g", "AppleInterfaceStyle"],
- stderr=subprocess.DEVNULL
- ).decode().strip()
- return out.lower() == "dark"
- except:
- return False
- # Linuxは省略
- return False
- class CueGUI(QWidget):
- def __init__(self):
- super().__init__()
- self.setWindowTitle("CUE分割ツール ぶったぎらー!! GUI版 V1.0(buttagira)")
- self.resize(500, 250)
- self.config = load_config()
- self.script_path = self.config.get("script_path", "")
- self.dark_mode = detect_dark_mode()
- self.setStyleSheet("background-color: #2b2b2b; color: white;" if self.dark_mode else "")
- layout = QVBoxLayout()
- self.script_label = QLabel(f"分割スクリプト: {os.path.basename(self.script_path) if self.script_path else '未設定'}")
- layout.addWidget(self.script_label)
- self.btn_change_script = QPushButton("分割スクリプトを変更")
- self.btn_change_script.clicked.connect(self.select_script)
- layout.addWidget(self.btn_change_script)
- self.cue_label = QLabel("CUEファイル: 未選択")
- layout.addWidget(self.cue_label)
- self.btn_select_cue = QPushButton("CUEファイルを選択")
- self.btn_select_cue.clicked.connect(self.select_cue)
- layout.addWidget(self.btn_select_cue)
- self.out_label = QLabel("出力フォルダ: 未選択")
- layout.addWidget(self.out_label)
- self.btn_select_out = QPushButton("出力フォルダを選択")
- self.btn_select_out.clicked.connect(self.select_out_dir)
- layout.addWidget(self.btn_select_out)
- self.btn_start = QPushButton("分割開始")
- self.btn_start.clicked.connect(self.start_split)
- layout.addWidget(self.btn_start)
- self.progress = QProgressBar()
- self.progress.setRange(0, 0)
- self.progress.setVisible(False)
- layout.addWidget(self.progress)
- self.setLayout(layout)
- self.cue_path = ""
- self.out_dir = ""
- def select_script(self):
- path, _ = QFileDialog.getOpenFileName(self, "分割スクリプトを選択", "", "Python Files (*.py)")
- if path:
- self.script_path = path
- self.script_label.setText(f"分割スクリプト: {os.path.basename(path)}")
- self.config["script_path"] = path
- save_config(self.config)
- def select_cue(self):
- path, _ = QFileDialog.getOpenFileName(self, "CUEファイルを選択", "", "CUE Files (*.cue)")
- if path:
- self.cue_path = path
- self.cue_label.setText(f"CUEファイル: {os.path.basename(path)}")
- def select_out_dir(self):
- dir_path = QFileDialog.getExistingDirectory(self, "出力フォルダを選択")
- if dir_path:
- self.out_dir = dir_path
- self.out_label.setText(f"出力フォルダ: {dir_path}")
- def start_split(self):
- if not self.script_path or not self.cue_path:
- QMessageBox.warning(self, "エラー", "分割スクリプトとCUEファイルを選択してください")
- return
- if not self.out_dir:
- self.out_dir = os.path.join(os.path.dirname(self.cue_path), "split_output")
- self.out_label.setText(f"出力フォルダ: {self.out_dir}")
- self.progress.setVisible(True)
- self.btn_start.setEnabled(False)
- QApplication.processEvents()
- cmd = [sys.executable, self.script_path, self.cue_path, self.out_dir]
- ret = subprocess.run(cmd)
- self.progress.setVisible(False)
- self.btn_start.setEnabled(True)
- if ret.returncode == 0:
- QMessageBox.information(self, "完了", "分割処理が完了しました!")
- else:
- QMessageBox.critical(self, "エラー", "分割処理中にエラーが発生しました")
- if __name__ == "__main__":
- app = QApplication([])
- window = CueGUI()
- window.show()
- sys.exit(app.exec())
Advertisement
Add Comment
Please, Sign In to add comment