분류 전체보기408 Running external commands & processes 28. Running external commands & processes So far we’ve looked at how to run things in separate threads, including external programs using Python subprocess. But in PyQt6 we can also make use of a Qt- based system for running external programs, QProcess. Creating and executing a job with QProcess is relatively straightforward. The simplest possible example is shown below — we create a QProcess ob.. 2023. 3. 13. Long-running threads Long-running threads Using QThread A simple thread concurrent/qthread_1.py import sys import time from PyQt6.QtCore import QThread, pyqtSignal, pyqtSlot from PyQt6.QtWidgets import QApplication, QLabel, QMainWindow class Thread(QThread): """ Worker thread """ result = pyqtSignal(str) # @pyqtSlot() def run(self): """ Your code goes in this method """ print("Thread start") counter = 0 while True: .. 2023. 3. 13. QRunnable examples QThreadPool 및 QRunnable은 다른 스레드에서 작업을 실행하는 매우 유연한 방법입니다. 신호와 파라미터를 조정하여 상상할 수 있는 모든 작업을 수행할 수 있습니다. 이 장에서는 특정 시나리오에 대한 러너를 구성하는 방법에 대한 몇 가지 예를 살펴보겠습니다. All the examples follow the same general pattern — a custom QRunnable class with custom WorkerSignals. The difference is in what we pass to the runner, what it does with those parameters, and how we hook up the signals. [basic] concurrent/qrunnab.. 2023. 3. 13. Using the thread pool QApplication 객체에서 .exec() 를 호출하여 시작된 이벤트 루프는 파이썬 코드와 동일한 스레드 내에서 실행됩니다. 이 이벤트 루프를 실행하는 스레드(GUI 스레드)는 호스트 운영 체제와의 모든 창 통신도 처리합니다. 기본적으로 이벤트 루프에 의해 트리거된 모든 실행은 이 스레드 내에서도 동기적으로 실행됩니다. 실제로 이것은 PyQt6 응용 프로그램이 코드에서 무언가를 할 때마다 창 통신 및 GUI 상호 작용이 정지된다는 것을 의미합니다. 수행중인 작업이 간단하고 GUI 루프에 제어를 신속하게 반환하면이 동결은 사용자가 감지 할 수 없습니다. 그러나 큰 파일 열기 / 쓰기, 일부 데이터 다운로드 또는 복잡한 이미지 렌더링과 같이 더 오래 실행되는 작업을 수행해야하는 경우 문제가 발생할 수 있.. 2023. 3. 13. Using Custom Widgets in Qt Designer 2023. 3. 13. Creating Custom Widgets Custom Widgets As we’ve seen, Qt comes with a wide range of widgets built-in, which you can use to build your applications. Even so, sometimes these simple widgets are not enough — maybe you need an input for some custom types, or want to visualize data in a unique way. In Qt you are free to create your own widgets, either from scratch or by combining existing widgets. In this chapter we’ll see .. 2023. 3. 13. Bitmap Graphics in Qt 21. Bitmap Graphics in Qt The first step towards creating custom widgets in PyQt6 is understanding bitmap (pixel-based) graphic operations. All standard widgets draw themselves as bitmaps on a rectangular "canvas" that forms the shape of the widget. Once you understand how this works you can draw any custom widget you like! INFO: Bitmaps are rectangular grids of pixels , where each pixel (and it.. 2023. 3. 13. Querying SQL databases with Qt models databases/tableview.py import os import sys from PyQt6.QtCore import Qt from PyQt6.QtWidgets import QApplication, QMainWindow, QTableView class MainWindow(QMainWindow): def __init__(self): super().__init__() self.table = QTableView() # self.model = ? # self.table.setModel(self.model) self.setCentralWidget(self.table) app = QApplication(sys.argv) window = MainWindow() window.show() app.exec() Con.. 2023. 3. 13. Tabular data in ModelViews, with numpy & pandas 모델이 Qt가 이해할 수있는 형식으로 해당 데이터를 반환하는 한 모든 데이터 소스에서 모델 뷰를 사용할 수 있습니다. Python에서 표 형식 데이터로 작업하면 해당 데이터를 로드하고 작업하는 방법에 대한 여러 가지 가능성이 열립니다. 여기에서는 간단한 중첩 목록 목록으로 시작한 다음 Qt 응용 프로그램을 인기있는 numpy 및 pandas 라이브러리와 통합하는 단계로 이동합니다. 이렇게 하면 데이터 중심 응용 프로그램을 빌드하기 위한 훌륭한 기반이 제공됩니다. Introduction to QTableView QTableView 는 스프레드 시트와 같은 테이블보기로 데이터를 표시하는 Qt 뷰 위젯입니다. 모델 뷰 아키텍처의 모든 위젯과 마찬가지로 이 위젯은 별도의 모델을 사용하여 뷰에 데이터 및 프리젠테.. 2023. 3. 13. 이전 1 ··· 31 32 33 34 35 36 37 ··· 46 다음