The problem I am experiencing is that when I want to create a button which is supposed to do a certain action on being pressed, the action happens right away when the program starts. In clearer terms, I have an os.system("sudo python /home/pi/module2.py")
in a function. This is what the function might look like (oh, yeah, I imported os, and tkinter as tk):
def __init__(self, parent, controller):
button = tk.Button(self,
text="Addition",
command=os.system("sudo python /home/pi/module2.py")
What happens with this is that the os.system
function is run before anything else starts, because it is in a function at the top of the file, and I call on the functions at the bottom of the file. So, even though the os.system
is in a function, it still runs when it shouldn't. Can someone help?