Python 在gui中使用qprocess启动脚本在3.4中有效,而不是挂在原始输入上的2.7?

Python 在gui中使用qprocess启动脚本在3.4中有效,而不是挂在原始输入上的2.7?,python,python-2.7,user-interface,pyqt,qprocess,Python,Python 2.7,User Interface,Pyqt,Qprocess,我在AnacondaIDE和Python3.4中完成了gui应用程序的所有开发,并使用了一个简单的测试脚本,我认为它在3.4中运行良好,可以实时显示输出并等待输入。该应用程序的最终目标是运行一个我无法控制的脚本,并在2.7中进行编码,然后发送脚本命令。我已经转换了足够多的gui脚本,可以在2.7中使用,但qprocess并没有按预期工作。对于简单的测试脚本,假设它挂起在原始输入上,则根本不显示任何内容。当我运行所需的脚本时,不会显示任何内容,然后所有内容都会显示消息,显示它已关闭(可能它有超时功

我在AnacondaIDE和Python3.4中完成了gui应用程序的所有开发,并使用了一个简单的测试脚本,我认为它在3.4中运行良好,可以实时显示输出并等待输入。该应用程序的最终目标是运行一个我无法控制的脚本,并在2.7中进行编码,然后发送脚本命令。我已经转换了足够多的gui脚本,可以在2.7中使用,但qprocess并没有按预期工作。对于简单的测试脚本,假设它挂起在原始输入上,则根本不显示任何内容。当我运行所需的脚本时,不会显示任何内容,然后所有内容都会显示消息,显示它已关闭(可能它有超时功能无法检查)。不幸的是,我不能发布实际的脚本,但我已经将代码归结为这个简单的测试用例,它不适合我。我认为问题在于没有实时读取脚本输出,进程没有正确地等待输入。我怎样才能在2.7中实现这一点

mainwindow.ui:

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>562</width>
    <height>608</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <widget class="QWidget" name="centralWidget">
   <layout class="QVBoxLayout" name="verticalLayout">
    <item>
     <layout class="QHBoxLayout" name="horizontalLayout">
      <item>
       <widget class="QLineEdit" name="fileLocation"/>
      </item>
      <item>
       <widget class="QPushButton" name="openFileButton">
        <property name="text">
         <string>OpenFile</string>
        </property>
       </widget>
      </item>
      <item>
       <widget class="QPushButton" name="startButton">
        <property name="text">
         <string>Start</string>
        </property>
       </widget>
      </item>
     </layout>
    </item>
    <item>
     <widget class="QTextBrowser" name="textBrowser"/>
    </item>
   </layout>
  </widget>
  <widget class="QMenuBar" name="menuBar">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <width>562</width>
     <height>21</height>
    </rect>
   </property>
  </widget>
  <widget class="QToolBar" name="mainToolBar">
   <attribute name="toolBarArea">
    <enum>TopToolBarArea</enum>
   </attribute>
   <attribute name="toolBarBreak">
    <bool>false</bool>
   </attribute>
  </widget>
  <widget class="QStatusBar" name="statusBar"/>
 </widget>
 <layoutdefault spacing="6" margin="11"/>
 <resources/>
 <connections/>
</ui>
test.py是为python 2.7编写的:

print "running script 2" 
print "Enter an input A,B,C:"

s=raw_input("")
print "you selected:"+s

脚本的Python版本可能与GUI的不同,因为您正在启动一个外部进程。因此,您可以让GUI在Python3.4中运行,而脚本在Python2.7中运行。只需确保指定要使用的Python可执行文件的完整路径

你能发布3.4版本的脚本吗?是的:
print(“运行脚本2”)print(“输入A、B、C:”)s=input(“”)print(“你选择的:”)
你能尝试
print(“运行脚本2”)print(“输入A、B、C:”)s=str(输入(“”)print(“你选择的:“+s”)吗
在python 2.7测试中?ui文件与main.py脚本中所有编码垃圾的相关性如何?请阅读关于如何提供用户界面的指南。我包括了用户界面文件,这样人们就可以在不做任何工作的情况下运行代码。如果您尝试在没有ui文件的情况下运行代码,您只会遇到一些错误,无法获得一个工作示例。这并不能解决我的问题。这是100%肯定会工作的,没有理由转换GUI脚本。然而,您尝试实现我所描述的内容的方式可能存在其他问题,或者仅存在与上述内容无关的其他问题。我建议您运行3.4应用程序来执行3.4脚本,并验证它是否运行;然后用2.7脚本替换3.4脚本,保留3.4应用程序。如果这不起作用,用代码发布一个新的问题。即使上面显示的简单测试代码,主脚本在3.4中运行,测试启动子流程在2.7中运行,它仍然没有提供任何输出。
print "running script 2" 
print "Enter an input A,B,C:"

s=raw_input("")
print "you selected:"+s