Is there any way on using external widgets that are written in C++ in a Python GUI which is made with PyQt5?
I want to use bushuhui qFlightInstruments or merek qFlightInstruments in a GUI which I made for an underwater robot using PyQt5, but I haven't been able to implement this since I don't understand C++.
Related
I'm trying to make a python GUI application that handles some sort of data. Then I expect to make the user capable of manipulating that data using python scripts, form within the GUI, using a script interpreter with the data exposed as pre-existing objects. Pretty much like VBA is embedded in MSWord or the way you can embed python on a C application (see here).
Is there any technique or library to do this?
Has this been achieved in some project before?
One way to do it would be to write a GUI in PyQt, and then embed an iPython console inside the GUI as a GUI widget.
Check out this answer:
Embedding IPython Qt console in a PyQt application
and a couple other suggestions here:
https://github.com/ipython/ipython/issues/9508
A different non-PyQt approach is described here:
https://www.pythoncentral.io/embed-interactive-python-interpreter-console/
We have a large library and utility tools written in Python 2.7. And we need to create a GUI application that uses these python library and tools. So I'm looking for a solution that can easily interact between the GUI app and our python code base.
Requirements:
cross-platform: Linux, Windows;
these programming languages are preferred: C++, C#, Python.
Performance is not very essential. The key is to quickly develop the
GUI application;
I know that PyQt can be a good choice but what concerned me is - if we are to develop the GUI in Qt C++, interact with Python may not as easy as the other way round, i.e. python code can easily use Qt library because of PyQt but C++ code does not have something similar. When we have controls made in Qt C++, it would not be straightforward to use them in python.
Any suggestions? Thanks.
I know in PythonQt I can access MOC'd QObject based classes in Python code and that python code can be executed from C++. Is it possible to do something similar using PyQt or is it intended to be used only to write Qt in Python?
I understand SIP is used to expose C/C++ code to Python but that doesn't seem to be as elegant as using the meta-object system.
I have never used PythonQt, but after a brief skim of the features, it seems that, in terms of conceptual emphasis, it really should have been called QtPython.
PyQt started life as a tool for prototyping Qt C++ applications in python. As a consequence, it was originally a very thin wrapper around the Qt library, which made it almost trivial to port Qt code from python to C++ and vice versa. And it still is quite easy to do this. But since PyQt4, the emphasis has shifted strongly towards making it easier to write Qt applications in Python; and with PyQt5, it has moved even further in that direction.
So PyQt is now intended purely for writing Qt applications in python (and the same goes for PySide). It does not provide any facility for executing python code within C++ (other than indirectly via virtual functions). If you need to expose third-party Qt classes to python, you would need to wrap them using Sip.
As for the meta-object system: PyQt does wrap QMetaObject and so forth, but there is not enough information in your question to know whether that would be of any use to you.
I do automation and currently automating an application made with QT (C++).
I use Squish to do this using Python scripting language.
Can someone explain me exactly how a Python variable can be assigned a C++ Object?
Do you need to refer C++ built-in types (int, long, char, wchar_t, etc.) and arrays in Python code? If so you need to use ctypes Python package. Here is an example of calling C++ dll function from Python. If you need to send Window message (like WM_CLICK) take a look at ctypes.Structure class. There are some examples of C structures declared in Python code.
EDIT: Currently I know 2 open source projects about QT GUI automation.
funq
GammaRay
Also it's possible to build and run QT app with accessibility features for Windows UIA and Linux AT-SPI.
I googled and search stackoverflow before asking this question
Answers that I don't expect:
wxWidgets is the best Python GUIUse TkInter (BIM) for GUI development.
Q. How to make a GUI without using any module/library? i.e make a GUI from scratch. Modules like tkinter not allowed.
I've made several GUIs from scratch using SDL which is a low level drawing library. The advantage of doing that is that it will look exactly the same on any platform down to the pixel and you can get it to work on embedded systems. Full screen GUIs are really easy too. Disadvantages are that it is a lot of work.
In python the pygame library wraps SDL so you would use that, and in fact that is how I made the GUI for a lab instrument which had a large colour LCD screen. The controller ran linux, but not X-windows.
pygame is an extra library, yes, but I can't think of a way of making a GUI with only what python provides.
The easiest GUI to make without "module/library" is a web-based one. I.e. generate HTML with Javascript from your Python code, and let the Javascript interact via AJAX with your Python app. This can be implemented without too much effort with just the standard Python library (and some JS code, of course), or with modules that don't require "heavy" installation of platform-specific extensions.