Due to license restrictions I do not want to use QTCharts, so I am looking at PyQtGraph library.
I am working with PySide2 and QML. I am having difficulty getting a simple example working using QML because I don't know where to start. How do I embed one of these charts from the Python/Pyside2 backend to the QML front end?
Do I need to use a QQuickWidget somehow? Anyone have any examples of how to do this?
Can someone please point me in the right direction? Thank you
pyqtgraph is based on QGraphicsView which is part of the Qt Widgets submodule, so what you are asking for is equivalent to asking that a Qt Widget be embedded in QML and that is not possible. QQuickWidget does the opposite, ie embed a QML in a Qt Widget. In conclusion you can not.
Related
I'm quite new to pyqt and pyqtgraph so my apology if I'm missing basic things.
I have python program that acquires and plots data, where GUI is implemented by enaml. However the speed of MPL Canvas (matplotlib) was intolerably slow for realtime plotting application, therefore I wish to enhance the performance utilizing pyqtgraph. Immediate conflict seen is that enaml needs to have
from enaml.qt.qt_application import QtApplication
app=QtApplication()
while in order to use pyqtgraph the following seems necessary.
from pyqtgraph.Qt import QtGui, QtCore
app = QtGui.QApplication([])
Can enaml and pyqtgraph coexist or can at least embed pyqtgraph within the enaml thread? If someone can give me a clue it would be a great help. Thanks.
Yes they can exist together. You can create your own declaration and toolkit widgets or use the one from enamlx.
There's an example https://github.com/frmdstryr/enamlx/blob/master/examples/plot_area/plot_area.enaml
This question is the exact same as this one except that I'm looking for such a widget to be used in PySide. Anyone knows some code out there that provide easy-to-reuse property editor widget?
There is the proposal of using QTreeView or QTableView to build such a widget that is an option with PySide, but this is not a straight forward solution...
I don't know if you would be OK with this, but if you are happy to add the whole of pyqtgraph as a dependency, then you might want to try using pyqtgraph's ParameterTree.
There is a pretty comprehensive set of examples, just install pyqtgraph and then run:
import pyqtgraph.examples
pyqtgraph.examples.run()
Launch the ParameterTree example!
I want to develop an UI containing both forms for the user to configure the app and also a "render" part which will print some sprites for example.
Is it possible to combine PySide and PyGame in the same application? For example, how can i get a PySide Frame containing a Pygame application?
Thank you
The simplest, most natural solution is probably just to use a QGraphicsView. E.g. for sprites, implement a subclass of QGraphicsItem, and override the paint() function to display the appropriate frame.
If you absolutely insist on using PyGame, you could easily run the PySide and PyGame bits in separate windows. For embedding PyGame inside a PySide widget, it's probably going to be much harder, and the PySide widgets won't gel as seamlessly (you can actually stick GUI elements like buttons inside a QGraphicsView and transform them!).
I used Qt4Designer to design an application UI.
I did this but when I was converting it to a .py file via pyuic4 as below:
pyuic4 myui.ui > myui.py
I facet to an error that said: Error: Q3Support widgets are not supported by PyQt4.
what is this error's reason?
Can we use all widgets placed in designer? for example KDatePicker, Q3Table and etc.
The Q3Support classes are only there to help with porting a Qt3 application to Qt4. There's absolutely no reason to use them in new code. And in any case, they will be dropped completely for Qt5 (which is not far away now).
There's nothing much to add regarding the error message you got, as it could hardly be clearer. The Q3Support widgets are not supported by PyQt4. Which is to say, PyQt4 simply does not wrap any of those particular Qt classes.
As for the KDE widgets: they are not directly supported by PyQt either.
To use them with python, you would require PyKDE4 - and the ui files would need to be compiled with pykdeuic4.
I'm writing a basic program in python using the PyQt4 module. I'd like to be able to use my system theme's icons for things like the preference dialog's icon, but i have no idea how to do this. So my question is, how do you get the location of an icon, but make sure it changes with the system's icon theme? If it matters, i'm developing this under ubuntu 9.04, so i am using the gnome desktop.
Unfortunately, It appears that Qt does not support getting icons for a specific theme. There are ways to do this for both KDE and Gnome.
The KDE way is quite elegant, which makes sense considering that Qt is KDE's toolkit. Instead of using the PyQt4.QtGui class QIcon, you instead use the PyKDE4.kdeui class KIcon. An example of this is:
from PyKDE4.kdeui import *
icon = KIcon("*The Icon Name*")
see the PyKDE documentation for this class, here.
One way to gain support for this for gnome is to use the python gtk package. It is not as nice as the kde way, but it works none the less. It can be used like this:
from PyQt4 import QtGui
from gtk import icon_theme_get_default
iconTheme = icon_theme_get_default()
iconInfo = iconTheme.lookup_icon("*The Icon Name*", *Int of the icon size*, 0)
icon = QtGui.QIcon(iconInfo.get_filename())
See the documentation for the Icon Theme class and Icon Info class.
EDIT: thanks for the correction CesarB
Use the PyKDE4 KIcon class:
http://api.kde.org/pykde-4.2-api/kdeui/KIcon.html
I spent a decent amount of researching this myself not long ago, and my conclusion was that, unfortunately, Qt doesn't provide this functionality in a cross-platform fashion. Ideally the QIcon class would have defaults for file open, save, '+', '-', preferences, etc, but considering it doesn't you'll have to grab the appropriate icon for your desktop environment.