pyqt6-patterns
Best practices and patterns for building robust PyQt6 desktop applications
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Best practices and patterns for building robust PyQt6 desktop applications
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Best practices for robust Excel data processing with Pandas and OpenPyXL
Git workflow patterns, commit conventions, and edge case handling for Antigravity projects
Guide for packaging Python apps with PyInstaller for Windows and macOS
| name | pyqt6-patterns |
| description | Best practices and patterns for building robust PyQt6 desktop applications |
Guide for building Desktop applications with PyQt6, focusing on architecture, threading, and user experience.
Use a model that separates UI and Logic:
main.py# Imports
from PyQt6.QtWidgets import ...
from PyQt6.QtCore import QThread, pyqtSignal
# 1. Background Thread Class
class WorkerThread(QThread):
progress = pyqtSignal(int, str)
finished = pyqtSignal(object)
error = pyqtSignal(str)
def run(self):
try:
# Heavy task here
pass
except Exception as e:
self.error.emit(str(e))
# 2. Main Window Class
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setup_ui()
def start_task(self):
self.thread = WorkerThread(...)
self.thread.progress.connect(self.on_progress)
self.thread.finished.connect(self.on_finished)
self.thread.start()
Inviolable Rule: NEVER run heavy tasks on the Main Thread.
Use QThread:
QThread.pyqtSignal) to communicate back to Main Thread.run() method.self.thread) in MainWindow.start().Always use Layouts for responsive UI:
QMainWindow
└── CentralWidget (QWidget)
└── QVBoxLayout
├── QGroupBox ("Input")
│ └── QFormLayout
├── QGroupBox ("Settings")
│ └── QVBoxLayout
└── QGroupBox ("Actions")
└── QHBoxLayout
Use Fusion style for a clean cross-platform look:
app = QApplication(sys.argv)
app.setStyle("Fusion")
In Worker Thread, always use try-except and emit error signal:
def run(self):
try:
# Dangerous code
do_work()
except Exception as e:
self.error.emit(str(e)) # Send error to UI
```
In UI, listen for signal and show MessageBox:
```python
def on_error(self, message):
self.btn_start.setEnabled(True) # Re-enable UI
QMessageBox.critical(self, "Error", message)
path = QFileDialog.getExistingDirectory(self, "Select Folder")
if path:
self.input_dir = path
self.label.setText(path)
progressBar.setRange(0, 0)emit(percent) from thread -> progressBar.setValue(percent)Use QTextEdit readonly to display realtime logs:
self.log_text = QTextEdit()
self.log_text.setReadOnly(True)
# Append log signal
self.log_text.append(message)
When activating this skill (generating code), print: "🎯 [SKILL ACTIVATED] pyqt6-patterns v1.0.0" "📋 Parameters:" " - Component: [MainWindow|WorkerThread|Dialog]" " - Pattern Applied: [Threading|Layout|Signal-Slot]"
Before applying major architectural changes: "I'm implementing the [Pattern Name] pattern for [Component]. This will structure the code as [Description]. Proceed?"