Newbie question, problem with functions

Rickard Karlsson rickard-karlsson at
Tue Sep 23 23:04:23 CEST 2003

I have wrote this little program, that is supposed to execute eg. the
Linux ls command  when you press a button. Te problem is that all the
commands are run automaticly and they won't run when I press the
associated button. Wath am I do wrong?

from Tkinter import *
import os

class App:

    def __init__(self, master):

        frame = Frame(master)
	b1 = Button(frame, text = "ls", command = self.execute('ls'))
	b2 = Button(frame, text = "ls -alh", command = self.execute('ls
	b3 = Button(frame, text = "pwd", command = self.execute('pwd'))

	b1.grid(column=0, row=1)
	b2.grid(column=0, row=2)
	b3.grid(column=0, row=3)

    def execute(self,com):

root = Tk()

app = App(root)


More information about the Python-list mailing list