본문 바로가기

분류 전체보기408

Working with command-line arguments 36. Working with command-line arguments If you have created an application which works with specific file types — for example a video editor that opens videos, a document editor that opens document files — it can be useful to have your application open these files automatically. On all platforms, when you tell the OS to open a file with a specific application, the filename to open is passed to t.. 2023. 3. 13.
Enums & the Qt Namespace 35. Enums & the Qt Namespace When you see a line like the following in your application, you might have wondered what the Qt.ItemDataRole.DisplayRole or Qt.ItemDataRole.CheckStateRole objects actually are. ë In earlier versions of PyQt there were also shortcut names such as Qt.DisplayRole, so you may still see these in code. In PyQt6 you must always use the long-form. All examples in this book u.. 2023. 3. 13.
System tray & macOS menus 34. System tray & macOS menus System tray applications (or menu bar applications) can be useful for making common functions available in a small number of clicks. For full desktop applications they’re a useful shortcut to control apps without opening up the whole window. Qt provides a simple interface for building cross-platform system tray (Windows) or menu bar (macOS) apps. Below is a minimal .. 2023. 3. 13.
Working with Relative Paths 33. Working with Relative Paths Paths describe the location of files in your filesystem. When we load external data files into our applications we typically do this using paths. While straightforward in principle, there are a couple of ways this can trip you up. As your applications grow in size, maintaining the paths can get a bit unwieldly and it’s worth taking a step back to implement a more .. 2023. 3. 13.
Extending Signals 2023. 3. 13.
Extending Signals 32. Extending Signals We’ve seen a basic introduction to signals already, but that only scratches the surface of what you can do with them. In this chapter we’ll look at how you can create your own signals and customize the data sent with them. Custom Signals So far we’ve only looked at signals that Qt itself provides on the built-in widgets. However, you can also make use of your own custom sig.. 2023. 3. 13.
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.