Python Forum
Why my program works from script but not from GUI?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why my program works from script but not from GUI?
#1
I have a RUN script that runs all programs from the project. The script is run after pressing the OK button in the interface (QtDesigner) and is run by the subprocess.call(['py', 'RUN.py']). All programs run by RUN are also executed with the subprocess command.

One of the scripts creates a temp.py script that is located in the working folder and not where all the scripts (including RUN). This script is used as a module by programs run by RUN.

The module is imported in this way:
import sys
sys.path.append(work_dir)
from temp import *
The problem is that two important programs are not started when RUN is started from the interface. (they work when the RUN program is run directly from python script)

This is the command:

subprocess.call([grid_path, "-p", work_dir+"/"+"grid.gpf", "-l", work_dir+"/"+"grid.glg"],cwd=work_dir,shell=True)

subprocess.call([dock_path, "-p", best_pose+"_ligremove.dpf", "-l", best_pose+"_ligremove.dlg"],cwd=work_dir,shell=True)
work_dir comes from the parameters.py module, which is included with the scripts and specifies the path to the working folder.

grid_path / dock_path also come from the parameters.py module and refers to the program paths that perform the action.

the temp.py script has the value best_pose.

cmd is added to allow programs to perform actions on files in the working folder

These programs run twice. The first time they work correctly when best_pose is taken directly from the parameters.py module (located in the same folder as RUN), and it doesn't work the second time when the best pose value is different and comes from the temp.py module (it is located in a different folder than RUN)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  script with imports works but pytest gives "ModuleNotFoundError"? Hpao 0 1,573 Jun-27-2021, 08:30 PM
Last Post: Hpao
  “NameError” “is not defined” script that I know works on other computers iamwithstupid 0 2,529 Nov-24-2020, 04:23 PM
Last Post: iamwithstupid
  script works in windows but not in linux ovidius80 2 2,749 Apr-29-2020, 02:10 PM
Last Post: ovidius80
  Script works when executed from command prompt but not when executed in SDP Tippex 0 2,015 Apr-07-2020, 04:26 PM
Last Post: Tippex
  How to write a script to execute a program need passing additional input? larkypython 2 2,533 Nov-23-2019, 04:38 AM
Last Post: larkypython
  The following script works but I need to take it one step further to milliseconds. yeto 1 2,019 Jul-19-2019, 04:15 AM
Last Post: micseydel
  How to launch a program through python script - Mac OS Mojave Aurimas 2 2,825 May-11-2019, 10:20 AM
Last Post: kritesh
  How do I activate my script when another program opens? jhave_21 3 3,839 Nov-23-2017, 08:29 AM
Last Post: heiner55
  Script works ok on windows but gives error on ubuntu papampi 3 4,055 Oct-11-2017, 04:17 PM
Last Post: papampi
  Dict KeyError in cgi-bin script, works fine via console dbsoundman 2 3,917 Jul-21-2017, 08:03 PM
Last Post: dbsoundman

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020