R
Rickard Karlsson
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)
frame.pack()
b1 = Button(frame, text = "ls", command = self.execute('ls'))
b2 = Button(frame, text = "ls -alh", command = self.execute('ls
-alh'))
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):
os.system(com)
root = Tk()
app = App(root)
root.mainloop()
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)
frame.pack()
b1 = Button(frame, text = "ls", command = self.execute('ls'))
b2 = Button(frame, text = "ls -alh", command = self.execute('ls
-alh'))
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):
os.system(com)
root = Tk()
app = App(root)
root.mainloop()