简体   繁体   English

用于在C / C ++和Python之间交换值的应用程序设计

[英]Application design for exchanging values between C/C++ and Python

I'm writing a C/C++ application, this application is used directly by the user to give inputs, basically numerical values like a precise values, a range and something like that, think about an UI with some pieces like: 我正在编写一个C / C ++应用程序,这个应用程序直接由用户使用来提供输入,基本上是数值,如精确值,范围等类似的东西,考虑一下如下的UI:

  • a numpad 一个小键盘
  • a slider 一个滑块
  • an input field for numbers 数字的输入字段

and this is the C/C++ part, i expect to get just a bunch of values from this piece of code, the problem is that this values: 这是C / C ++的一部分,我希望从这段代码中得到一堆值,问题是这个值:

  • must be sended to Python in some way 必须以某种方式发送给Python
  • can change in real time since my C/C++ is like an UI where things can change 可以实时更改,因为我的C / C ++就像一个可以改变事物的UI

i don't know of any design that can fit my request mainly because: 我不知道任何能满足我要求的设计主要是因为:

  • i know just the really basic stuff about Python, i can script something but i know nothing about Python internals 我只知道关于Python的基本内容,我可以编写脚本,但我对Python内部知识一无所知
  • i have no idea how to make C++ and Python work together and how to do this in a signal/slot logic ( supposing that the signal/slot design is the right one for this app ) 我不知道如何使C ++和Python协同工作以及如何在信号/插槽逻辑中执行此操作(假设信号/插槽设计是此应用程序的正确设计)
  • i have no idea how to provide my APIs to the users that would like to integrate my values in their own script for third part applications, imagine a random app that provides Python APIs too, i want to give to the user the option to code using both APIs in one script and maybe use this script in this third part application as any other set of APIs ( importing external APIs is possible when scripting in a third part application Python environment? ) 我不知道如何向想要在我们自己的脚本中为第三方应用程序集成我的值的用户提供我的API,想象一下提供Python API的随机应用程序,我想给用户提供使用代码的选项两个API都在一个脚本中,并且可能在第三部分应用程序中使用此脚本作为任何其他API集(在第三部分应用程序Python环境中编写脚本时可以导入外部API?)

That's how i would describe my problem and what i'm aiming to do, if something is not clear please comment. 这就是我如何描述我的问题以及我想要做的事情,如果事情不明确请发表评论。

recap : how to provide Python API from a C++ application using a signal/slot design in real time? 回顾 :如何使用信号/插槽设计实时从C ++应用程序提供Python API?

Thanks. 谢谢。

Check out Boost.Python . 查看Boost.Python It's a library which allows to use Python as a scripting language for a C++ program. 它是一个允许使用Python作为C ++程序脚本语言的库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM