[Tutor] Calling Program within Program
modulok at gmail.com
Fri Dec 10 07:43:42 CET 2010
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 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:
> 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 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
> 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 Choices:
> Sparkling Water; Milk; Orange Juice; Apple Juice *OR*\n\n **From Our
> 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