[Tutor] Calling Program within Program
patty at cruzio.com
patty at cruzio.com
Thu Dec 9 19:18:11 CET 2010
I would like to know how to call a program from within a program and what
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 files
BreakersCafe.txt and BreakersCafe.py. This is my primary program running
I have a subdirectory called C:\Users\StarShip\PyProg \PicturesForTesting
and another subdirectory C:\Users\StarShip\PyProgs\CustomFunctions with
various program files, functions defined in them, etc. which I import in
my primary program. For example:
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 to
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 :} but
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 BeveragesMenu.py.
Program file for displaying an image using Tkinter built-in GUI functions.
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 to
--> 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
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 Choices:
Sparkling Water; Milk; Orange Juice; Apple Juice *OR*\n\n **From Our
Bar** Smoothie; Breakers Sun Tea; Chai; Cafe Mocha; Latte;
More information about the Tutor