[Tutor] embarrassingly basic Tkinter question...
klappnase at freenet.de
Mon Jun 28 06:06:34 EDT 2004
On Sun, 27 Jun 2004 22:13:31 -0400
Marv Boyes <marvboyes at att.net> wrote:
> Here's what I have so far:
> from Tkinter import *
> from os import system # now what?
> root = Tk()
> root.title("Melody's Internet Stuff")
> app = Frame(root)
> bttn1 = Button(app, text = "Connect to the Internet")
> bttn2 = Button(app, text = "Get, read, and write e-mail")
> bttn3 = Button(app, text = "Browse the Web")
> bttn4 = Button(app, text = "Close",command = 'exit')
> Now, what I want to do is launch an application by pressing buttons 1,
> 2, or 3. I'm guessing that the os module is involved, but I found that a
> simple command = system('appname') launched the application as soon as I
> ran the Python script; indeed, my Tk window wouldn't even appear until
> that application was closed. So I'm obviously missing something.
Probably you did something like:
within your code and as you told python it launched the browser and then waited until the system command had finished.
If you want to run programs in the background use
The second problem is that you of course don't want the program to be started with your app, but just
when the corresponding button is pressed. To achieve this you have to define a function for
each button callback, like this:
bttn3 = Button(app, text = "Browse the Web", command=browse_the_web)
I hope this helped
More information about the Tutor