如何使用ControlP5按钮激活/运行另一个处理脚本

发布于 2025-02-05 20:50:22 字数 237 浏览 1 评论 0原文

我当前的文件夹结构就像

- Parent
   - Child1
      - Child1.pde 
   - controlp5_GUI
      - controlp5_GUI.pde
  

我计划在ControlP5_GUI.PDE中使用ControlP5一样。我的最终目标是在用户单击“激活脚本”按钮时运行child1.pde。这在ControlP5中是否可行?如果是这样,怎么样?

My current folder structure is like

- Parent
   - Child1
      - Child1.pde 
   - controlp5_GUI
      - controlp5_GUI.pde
  

I plan to use controlp5 inside controlp5_GUI.pde. My final objective is to run child1.pde when the user clicks "Activate Script" button. Is this doable in controlp5? If so, how?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无人问我粥可暖 2025-02-12 20:50:22

您可以使用 exec() 呼叫 processing-java 命令行实用程序启动child1.pde。
例如,

Process sketch = exec("processing-java","--sketch=/absolute/path/to/yourSketch.pde","--run");

在您的情况下,controlp5_gui.pde会称呼类似:

Process sketch = exec("processing-java","--sketch=/Users/mac/Desktop/xxx/Child1","--run");

有几个警告需要考虑:

  1. 您需要processing-java将包含在path> path环境变量中 该与处理可执行文件(在已安装的处理的文件夹中)。
  2. (否则,您将需要提供与processing-java的绝对路径, /code>路径必须是绝对的

。 也可能会有所帮助

如果您需要使用P5从另一个草图中控制草图 “ rel =“ nofollow noreferrer”> ControlP5的帧示例有用。

You can use exec() to call the processing-java command line utility to launch Child1.pde.
e.g.

Process sketch = exec("processing-java","--sketch=/absolute/path/to/yourSketch.pde","--run");

In your case controlp5_GUI.pde would call something like:

Process sketch = exec("processing-java","--sketch=/Users/mac/Desktop/xxx/Child1","--run");

There are a couple of caveats to take into account:

  1. You need processing-java to be included into the PATH environment variable (otherwise you will need provide the absolute path to processing-java which lives in the same folder as the processing executable (in the folder where you've installed Processing).
  2. The --sketch path needs to be absolute.

This similar answer might be helpful too.

If you need to control a sketch from another sketch using P5 you might find ControlP5's frame example useful.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文