I have a very simple UI in Python and i want to run a Powershell Script when a Button is presed. The Problem is, that the Script is being run without pressing the button.
These are the two relevant functions:
def create_buttons(self):
self.setup = tk.Button(self, text="Bot Setup", command=self.powershell_setup())
self.setup.pack(side="top", pady = 10, padx = 10)
self.quit = tk.Button(self, text="QUIT", fg="red",command=self.master.destroy)
self.quit.pack(side="bottom")
def powershell_setup(self):
psxmlgen = subprocess.Popen([r'C:\\WINDOWS\\system32\WindowsPowerShell\\v1.0\\powershell.exe',
'-ExecutionPolicy',
'Unrestricted',
'./setup_bot_task.ps1'], cwd=os.getcwd())
BTW: I am using Tkinter as a GUI Framework