I want to build an application designed in C# forms Visual studio to get user input and want to process user input using python code? In python code, it has different methods to execute for each user input. I used simply for loops for that in python code.
How is it possible?
C# and Python are not compatible in that way. C# runs on .NET platform and Python runs in an interpreter written in C. You could try using PythonSharp, but it will be far from ideal (it's an old project). You could also write the whole application in Python with GUI toolkits. Most popular ones I know of are Tkinter and PyQT.
Edit: another project you might be interested in is IronPython.
Related
I would like to know if i can have a mobile application written on Python(for example, for interface), but with embedded C++ for some tasks or functions of the app? For example, an application written with Kivy Framework for its interface, and with C++ for some AI features. Thanks.
It is possible to write the necessary library in C++ and then use it in Python. Though this is going to require some tricks that you can find online as you make your library. One example of this (since you want to use AI) is TensorFlow; it is used in Python while its core is written in C++
I am building an application in which I would like to control Visual Studio, or at least have access to its compilation and build functionalities using (hopefully) python. I know Visual Studio macros are possible and available but it appears they are in .NET (see doc). Since I would like to automate what I want to do with VS in python I'm looking more for something along the lines of:
import vs2016 as controller
controller.build()
controller.compile()
Please note I am not looking to run python code in Visual Studio. This is an altogether different problem that is already widely documented by Microsoft.
Is it possible to control Visual Studio within Python?
if so, how?
if not, what is a viable alternative? let's say I accept that it can only be done with dotnet. In this case how can I relay back to python while keeping it debuggable from a python script?
Thanks!
This sounds like a pretty big undertaking, but I would look in to a win32com.client.dispatch or comtypesto plug in to the COM object(there are several from a quick search and I dont know what any of them do)
Can we use any IRONPython editor to develop scripts for Tibco Spotfire controls.
Can we use IDLE editor to develop IRONPython scripts for Tibco Spotfire? If yes then how to integrate the tibco module with IDLE editor, Can anyone help on this??
You should be able to use any development tool (ide) which supports ironpython. One of the best in my point of view is PTVS (Python Tools for Visual Studio), just search for it. But when you want some thing very lightweight with only some syntax hilighting, i prefer using Visual Studio Code or Atom. But PTVS has a lot of nice features. One of the most important ones are those for debugging, because they prevent you from using some console printing or some thing similar as debugging tool. Just take a look at it.
EDIT
As far as i can see, it should work just fines with PTVS. Taking a look at this, is't just some API as any other api: API-Doc
Spotfre has its own IDE for developing scripts but it is very poor one when analysing its functionalities. I dont think you can use any IDE to debug the scripts but you can at least use the one suggested by BendEg to make creation of the code more 'pleasant'.
Spotfire uses IronPython, which is a .NET implementation of python. In other words, is .NET driven by python. To test simple python functions, you can use CodeSkulptor, a cloud based python interpreter. For IronPython, you can use this java based online version but again, this is to test simple scripts
I've been messing around with Selenium in python, and I really want to have an existing C++ program run my python code.
Basically, my python code just finds a website, and downloads the file which afterwards my C++ program wants to open the file and do a bunch of operations on it. If I had a myPythonCode.py file, and my other C++ files (header.h, main.cpp, otherFunctions.cpp...) how would I go about running the python code from my C++ program?
Also both of my programs are console programs, and I was hoping that a user would have an uninterrupted experience running the program (for example, if the user wants to download a file while running the C++ program the terminal doesn't have to close, or open a different window to start the python program). Any help in going about this would be greatly appreciated!
It is operating system specific, and the C++11 standard does not define any functions for that (except system(3), which is in C99, and std::system in C++11). On Linux (and other POSIX systems), read Advanced Linux Programming and consider using system, or popen(3), or more probably the lower-level syscalls(2) like fork(2), execve(2), pipe(2), dup2(2), etc etc.... You may want some IPC and you may need to have some event loop around a multiplexing syscall like poll(2)
You could use some C++ frameworks like Qt or Poco (both have a process abstraction and are usable on several operating systems, even on proprietary ones from Microsoft)
If you want your C++ program to have a terminal interface on Linux, consider ncurses and/or readline
BTW, several C or C++ libraries for HTTP exist, e.g. libcurl for HTTP client side, and libonion for HTTP server side. So you might avoid your Python program and incorporate the downloading in your C++ application.
Check out the boost library which allows running python on C++ and using your C++ in python. https://www.boost.org/doc/libs/1_49_0/libs/python/doc/
I got curious and have been reading about GUI development using Python for the past hour. After reading documentation of wxPython, PyQt, Nokia's Python bindings for Qt along with Tkinter a question came to my mind.
When I create a console application with Python, it runs using the embedded Python interpreter (which I assume is usually if not always in my case cpython).
So I was wondering, what's the case with these "widget toolkits"?
How is the Python code executed and what interprets it (or executed it)?
Which part of my Python code is interpreted using the Python
interpreter?
Or does the Python code get lexically analysed and then parsed by the widget's
toolkit which then interpretes and executes (or compile during build)?
I am looking forward to understanding what goes on in the background in comparison with Python applications' (a bit simpler to understand) interpretation with the Python interpreter.
Thank you.
PS. To whichever genius thinks that this question deserves to be closed;
A lot of people wonder the internals of external libraries and systems. Especially those which are not as simple as they look. There currently is not any question explaining this on SE.
This is just a really generalized high-level explanation about "GUI toolkits"...
Lets say you decide to use the Qt framework. This framework is written in C++. There are two different python bindings that can be used, allowing one to write a GUI application in python against the same API as the C++ version.
The python bindings provide a wrapping around calls into the C++ code. PyQt4 for instance uses sip, while PySide uses shiboken. These are just language wrapping tools that take specifications for how to map between the C++ objects and their intended python interface.
Ok, so you start using PyQt... All of the code you write has to pass through the python interpreter. Some of it may be pure python. Some of it will call into C++ libs to create things like your widgets. In Qt, there will be a C++ pointer associated with the python instance counterpart.
It is the C++ layer that is then communicating with the window manager of your platform, to turn platform-independent API calls into something platform specific, like how to exactly draw a button or menu.
Whether you create a console only or GUI based python application, it all goes through the python interpreter to interpret your python code. Something must interpret the python language for you.