I have a test environment in python. it is executed by the following command on the command prompt.
1) First i have to go to the dir where the .py file is
2) then i simply execute python filename.py and the GUI appears
Now i have to create a script which could open the GUI...i.e execute the command "python filename.py" from inside itself.. I tried the "system" command inside my script but the GUI did not appear.i.e i tried
system("python filename.py") but nothing appeared on the screen
Plz help.
17 176682 dshimer 136
Recognized Expert New Member
Forgive me if this seems too elementary, but without full code or output to examine I am stretching, did you import os? For example if test.py contains - import os
-
os.system('python hello.py')
and hello.py just prints hello, then - C:\tmp>python test.py
-
hello
should do what you are asking unless there are other path or module issues. When you say the GUI doesn't appear, does anything happen? Are there errors?
The python "Process Management" docs may be of help.
Forgive me if this seems too elementary, but without full code or output to examine I am stretching, did you import os? For example if test.py contains - import os
-
os.system('python hello.py')
and hello.py just prints hello, then - C:\tmp>python test.py
-
hello
should do what you are asking unless there are other path or module issues. When you say the GUI doesn't appear, does anything happen? Are there errors?
The python "Process Management" docs may be of help.
to run another python script from your script: -
import myscript
-
myscript.somefunc()
-
just like importing the standard modules.
Forgive me if this seems too elementary, but without full code or output to examine I am stretching, did you import os? For example if test.py contains - import os
-
os.system('python hello.py')
and hello.py just prints hello, then - C:\tmp>python test.py
-
hello
should do what you are asking unless there are other path or module issues. When you say the GUI doesn't appear, does anything happen? Are there errors?
The python "Process Management" docs may be of help.
Thanx for the prompt reply...but as u have asked...i had already imported os and executedthe following command from my python script:
os.system("pyth on filename.py")
no error message was flagged and the command was successfully executed leading to the command prompt again but the GUI did not appear.
What could be the probable reason.??
Initially i used to run the GUI by simply typing:
python filename.py
bartonc 6,596
Recognized Expert Expert
Thanx for the prompt reply...but as u have asked...i had already imported os and executedthe following command from my python script:
os.system("pyth on filename.py")
no error message was flagged and the command was successfully executed leading to the command prompt again but the GUI did not appear.
What could be the probable reason.??
Initially i used to run the GUI by simply typing:
python filename.py
Is your GUI Tkinter, or some other toolkit?
Is your GUI Tkinter, or some other toolkit?
i don't know about the tool kit...
it was made for some testing puposes. i load my test files into that and press a runtest button.
bartonc 6,596
Recognized Expert Expert
I have a test environment in python. it is executed by the following command on the command prompt.
1) First i have to go to the dir where the .py file is
2) then i simply execute python filename.py and the GUI appears
Now i have to create a script which could open the GUI...i.e execute the command "python filename.py" from inside itself.. I tried the "system" command inside my script but the GUI did not appear.i.e i tried
system("python filename.py") but nothing appeared on the screen
Plz help.
By any chance, do you give command line arguments when you call python manually? If so, try - system("python filename.py arg1 arg2")
By any chance, do you give command line arguments when you call python manually? If so, try - system("python filename.py arg1 arg2")
no there are no command line arguments . i just run python filename.py from the command prompt while running the GUI manually.
no there are no command line arguments . i just run python filename.py from the command prompt while running the GUI manually.
personally, i would not recommend this method of calling a python script from anther. The "cleaner" approach is to import it.
for example , in script called myscriptA.py, you have -
def displayGUI():
-
print "I am from myscriptA.py in functoin displayGUI"
-
return
-
then in myscriptB.py, you can call your GUI display function like this -
import myscriptA ##or from myscriptA import displayGUI
-
myscriptA.displayGUI()
-
Hi, I'm just trying to follow along and had a question.....is it that your script will run in a dos window but what you want is for it to run on IDLE?
ex: -
>>> for i in range(5):
-
print i
-
-
-
1
-
2
-
3
-
4
-
>>>
-
-
so if your saved that script as loop.py: -
for i in range(5):
-
print i
-
and then wrote: -
import os,sys
-
os.system(r"C:\python25\loop.py")
-
then saved it as testrun.py. If you execute testrun.py, it runs the loop in a dos window but you want it to execute and print out to IDLE instead? Is that it, or am I on the wrong track in trying follow?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Amir |
last post by:
Can one PHP script execute another PHP script?
|
by: Irmen de Jong |
last post by:
QOTW: "Confronting the Martellibot is like flirting with an encyclopedia,
I'd rather not do it myself, but I respect those who do, because it
produces knowledge." -- Anton Vredegoor
"Python and Java are not diametrically opposed religions that must fight
to the death in jihad, despite the existence of loonies favoring...
|
by: Steve |
last post by:
Hi,
I've written a small cgi python script that collects feedback from a
webform. I need to pass the values to another python script.. how do I
do this? Is this even possible? Thanks
Steve
|
by: Paul Cochrane |
last post by:
Hi all,
I've got an application that I'm writing that autogenerates python code
which I then execute with exec(). I know that this is not the best way to
run things, and I'm not 100% sure as to what I really should do. I've had a
look through Programming Python and the Python Cookbook, which have given me
ideas, but nothing has gelled...
|
by: Eric_Dexter |
last post by:
I was looking for a simple way to load a simple python program from
another python program.
I tried
os.system(cabel)
The file name is cabel.py a csound instrument editor..
The error I am getting is
| |
by: KraftDiner |
last post by:
I have a class that is defined in a file called MyClass.py
How do I use that class in another python script..
import MyClass ? (Does it need to be in a specific location?)
|
by: maya |
last post by:
hi,
I keep getting this error, "can't execute code from a freed script" when
I go to another page (i.e., upon UNLOAD..)
this error occurs only in IE, not FF (what a surprise.....;)
what is this error, pls.. it's for a site I've been working on for a
few weeks now, started getting this error just a few days ago.. (I
looked this up, saw...
|
by: Alexandru Mosoi |
last post by:
how do I execute another python script under a different process? I
want the script to be run using the same interpretoer as the one
running current script. I tried using os.execlp but I don't know how
to get the name/path of the interpreter.
|
by: gintrado |
last post by:
I am very new to Python I'm trying to run a python script from within another python script. I can run the script from a unix command line by typing: nohup python script.py password > /tmp/outfile.log 2>&1 & Or, I can put that command in a shell script and run it by typing: ./script.sh Both work great. However I don't know how to put...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |