본문 바로가기

PyQt5_47

Timers 31. Timers In applications you often want to perform some tasks regularly or even just at some point in the future. In PyQt6 this is accomplished by using timers. The QTimer class gives you access to two different types of timer — recurring or interval timers, and single shot or one off timers. Both can be hooked up to functions and methods in your application to cause them to execute whenever y.. 2023. 3. 13.
Plotting with Matplotlib. 30. Plotting with Matplotlib In the previous part we covered plotting in PyQt6 using PyQtGraph. That library uses the Qt vector-based QGraphicsScene to draw plots and provides a great interface for interactive and high performance plotting. However, there is another plotting library for Python which is used far more widely, and which offers a richer assortment of plots — Matplotlib. If you’re mi.. 2023. 3. 13.
Plotting with PyQtGraph 29. Plotting with PyQtGraph While it is possible to embed matplotlib plots in PyQt6 the experience does not feel entirely native. For simple and highly interactive plots you may want to consider using PyQtGraph instead. PyQtGraph is built on top of PyQt6 native QGraphicsScene giving better drawing performance, particularly for live data, as well as providing interactivity and the ability to easi.. 2023. 3. 13.
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.