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.
Related
I want to make a small application with graphical interface with Python but I want to do the calculations in another language such as C++ or Golang, is it possible ?
Build a .dll or .so file from your C++ source, then use Python's ctypes to import the functions from it. Alternatively, use the Python C API to create an extension module. The difference is that in the first approach, the interop code will be in Python, and in the second, it will be in your native code.
I need to access data via USB from a beam profiler. I've tried using the USB module in python to access it, but unfortunately the company who makes this device "does not support development in Python". The project I am working on is to eventually create a GUI (via Python) to automate a motor and pull data from the device. So it has to be done in Python, or I'm going to have to discard the first half of the code and redo it in C++.
I think the reason the device can only interface with C/C++ is because of the header and library files that come with the driver download.
I've looked at Cython but am still very unsure how it can help me. I'm just trying to access the header files for the driver in python and somehow execute the C commands in python.
BTW I am using Anaconda (if that matters).
Thank-you for any clarification and help!
Check out boost.python
Here is an intro:
The Boost Python Library is a framework for interfacing Python and
C++. It allows you to quickly and seamlessly expose C++ classes
functions and objects to Python, and vice-versa, using no special
tools -- just your C++ compiler. It is designed to wrap C++ interfaces
non-intrusively, so that you should not have to change the C++ code at
all in order to wrap it, making Boost.Python ideal for exposing
3rd-party libraries to Python. The library's use of advanced
metaprogramming techniques simplifies its syntax for users, so that
wrapping code takes on the look of a kind of declarative interface
definition language (IDL).
It includes support for:
References and Pointers
Globally Registered Type Coercions
Automatic Cross-Module Type Conversions
Efficient Function Overloading
C++ to Python Exception Translation
Default Arguments
Keyword Arguments
Manipulating Python objects in C++
Exporting C++ Iterators as Python Iterators
Documentation Strings
and many more.
I am supposed to develop GUI using python for an application coded in C++. It is to be used as a PyMOL plugin.
How do I decide among the different options like ctypes, Boost.Python, SWIG, wxPython or Pyrex(?)?
I'm quite new to Python and have had very little experience with C/C++.
Also, I have the Python code for GUI of a similar application. How can I identify the type of Python-C++ interface used in it?
I don't see any of the following in the Python code:
import wx
from ctypes import *
I am trying to create an application in which the GUI is programmed in Python (Tkinter) and I have a library in C++ that I want to interface with this GUI code. (Please, no comments on why the GUI and the application library are in separate languages).
One approach that immediately comes to mind is to compile the C++ library into an executable and write python wrappers that call this executable ( via system() ) with specific arguments and consume the output.
I am not sure what the performance implications are for such an implementation. Also I do not want to change the library into Python. Any better suggestions or comments on the approach?
There are several ways for doing this. One obvious way was already stated by chis. Another good way of interfacing C++ with Python is by using swig. It all comes down how complex your structures / classes are.
So the C++ code is going to be a module in python and can be called by the interface as any other python function.
I want to write a computer algebra system for iOS (just for fun), and I think it would be better if the kernel code was written in Python. So I want a way to:
Call Python code from Objective-C on iOS,
Access the properties and methods of Python objects from Objective-C:
I am going to do all the GUI (View) code in Objective-C, I won't need to call Cocoa from Python.
Two options:
1) Use kivy (http://kivy.org/#home), its compatible with iOS but you'll have to write the UI in python (I haven't tried to do otherwise so there might be a way).
2) Use something like PyObjC (http://pyobjc.sourceforge.net/). You can write your logic in normal python modules and then use from objective-C UI code.