[Tutor] Calling Program within Program
patty at cruzio.com
patty at cruzio.com
Fri Dec 10 17:46:14 CET 2010
The code below is very simple, so I don't think you would have needed to
read it. I will review the subprocess doc and look this up in my books
and class notes. If I have more questions, I will email the group.
I also realized that I wasn't clear in asking a secondary question which
is what directory/directories to place files that are part of a program,
actually an application. As if you were creating a source code hierarchy
for the first time :} If I have more questions about that I will email
again and change the subject header.
Thanks for the reply!!
> I didn't read through your code, but to call an external program see
> the 'subprocess' module in the standard library:
> On 12/9/10, patty at cruzio.com <patty at cruzio.com> wrote:
>> I would like to know how to call a program from within a program and
>> directory I should place one small program file in. I am running Python
>> 2.6.6 and Windows 7.
>> I have a directory called C:\Users\StarShip\PyProgs and it has the
>> BreakersCafe.txt and BreakersCafe.py. This is my primary program
>> I have a subdirectory called C:\Users\StarShip\PyProg
>> and another subdirectory C:\Users\StarShip\PyProgs\CustomFunctions with
>> various program files, functions defined in them, etc. which I import
>> my primary program. For example:
>> def Newbanner():
>> print "\n Alternate Selections\n"
>> Now I have the small program below which is fully self-contained and I
>> want to execute it from within BreakersCafe.txt. I would like to use
>> raw_input and if statement for simple yes/no asking if they would like
>> see this BeveragesMenu.txt and have it as the last 3-4 lines of the
>> The only directory of these three that has __init__ is
>> and as you can see, the program below is not a function, it has no 'def'
>> anything. I get 'NameError: global name 'BeveragesMenu' is not defined'
>> when I run this in IDLE. I suppose I _could_ make this a function :}
>> it is likely doable to call a program as a program, right? I am also
>> compiling to a .pyw file where applicable.
>> Thanks for the help.
>> This is C:\Users\StarShip\PyProgs\BeveragesMenu.txt and
>> Program file for displaying an image using Tkinter built-in GUI
>> open root window, open file descriptor for image, open new window file
>> descriptor to manipulate with Tkinter Label library function.
>> Pic needs to be displayed as a banner. Uses the compound="top" argument
>> do this.
>> --> take out the pack()function didn't work, pack()is required
>> Uses import Tkinter
>> Program using new breaker's jpg picture; bar choices are not selectable
>> import Tkinter
>> import ImageTk
>> rootwindow = Tkinter.Tk()
>> image_var = ImageTk.PhotoImage(fhdl)
>> whdl = Tkinter.Label(rootwindow, compound="top", image=image_var,
>> text="\n\n!!!WELCOME TO BREAKER'S BREAKFAST BAR!!!\n\n\nBeverage
>> Sparkling Water; Milk; Orange Juice; Apple Juice *OR*\n\n **From
>> Bar** Smoothie; Breakers Sun Tea; Chai; Cafe Mocha; Latte;
>> Tutor maillist - Tutor at python.org
>> To unsubscribe or change subscription options:
More information about the Tutor