[Tutor] embarrassingly basic Tkinter question...
marvboyes at att.net
Sun Jun 27 22:13:31 EDT 2004
Hello, all. I'm roughly a week old as a Python programmer, and this is
my first post to the list (both of these facts will become painfully
obvious once you've read my question...)
I've been through all of the documentation I can get my hands on, and I
have yet to find a clear answer-- can anyone tell me a good way to
launch an application (under Linux) by clicking on a button created with
I've been able to create windows and widgets galore, but they're not
much use until I can convince them to DO something. I've been able to
make a button labeled 'Close' which (drumroll, please...) closes the
window. Beyond that, I'm not having much luck.
Basically, I want to create a simple menu application for my wife (who's
been lost on this machine since I switched to Xfce4) so she can launch
the programs she wants. Sure, I could slap launchers in Xfce4's panel,
but I like to keep it relatively clean. Besides, there's a problem that
needs solving, and I'd love to be able to do it myself, the way I want.
My wife will also be touched by my thoughtfulness, and forget how much I
spent on programming books last week. ;)
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.
Sorry this is so lengthy--I'll work on brevity. In the meantime, can
anyone point me in the right direction? Many thanks in advance.
Help in the research to fight devastating diseases like
Huntington's, Parkinson's, and Alzheimer's-- donate your computer's
leisure time to Folding at Home.
More information about the Tutor