[英]how to send data from one python script file to another in pygtk
I want to send data from one py file ( stuff.py
) to another py file ( start.py
) in pygtk means I want to send data from one window to another window which I will select in 1st. 我想将数据从一个py文件( stuff.py
)发送到pygtk中的另一个py文件( start.py
),这意味着我想将数据从一个窗口发送到另一个窗口,该窗口将在1st中进行选择。 so anybody let me know how to send data from one file to another file. 所以有人让我知道如何将数据从一个文件发送到另一个文件。
I am using subprocess
. 我正在使用subprocess
。
subprocess.call('start.py', shell=True)
First of all, you really should be talking about sending data from one PROCESS to another PROCESS—sending data between files doesn't make much sense (unless you're talking about taking content from file1 and copy-pasting it to file2, but that's clearly not what this is about). 首先,您确实应该在谈论将数据从一个过程发送到另一个过程—在文件之间发送数据没有多大意义(除非您正在谈论从文件1中获取内容并将其复制粘贴到文件2中,但这就是显然不是这个意思)。
This is called IPC (Inter-Processes Communication). 这称为IPC(进程间通信)。 There are various ways how to do that; 有多种方法可以做到这一点。 to list a few options: 列出一些选项:
For more information, see https://en.wikipedia.org/wiki/Inter-process_communication . 有关更多信息,请参见https://en.wikipedia.org/wiki/Inter-process_communication 。
As to your question about subprocess.call(...)
—no, this will just invoke the other file creating a completely new process; 关于您有关subprocess.call(...)
-否,这只会调用另一个文件来创建一个全新的进程; this will in no way affect any existing processes, regardless of whether they are spawned from start.py
or not. 这将不会影响任何现有进程,无论它们是否从start.py
生成。 Also, to my best knowledge, whether your app uses pygtk or not, should be more or less irrelevant to the question of how to do IPC. 同样,据我所知,您的应用程序是否使用pygtk,应该与如何进行IPC的问题或多或少无关。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.