having a bash at using Tkinter - What I am trying to make is a small GUI which runs a system call function.
I want to be able to set v1, v2, v3 as string items using the GUI - they are for use in the "command" function.
def system_call( step_name, cmd ): try: subprocess.check_call(cmd, shell=True) except subprocess.CalledProcessError as scall: print "Script failed at %s stage - exit code was %s" % (step_name, scall.returncode) exit() def command(v1, v2, v3): # Commandline string return v1 + " " + v2 + " " + v3
Below you will find the interface set up.
# Create and name the window root = Tk() root.title("GUI - TEST VERSION") # Set the variables needed for function v1 = StringVar() v2 = StringVar() v3 = StringVar() # Make text entry box w = Label(root, text="V1") w.pack() text_entry = Entry(root, textvariable = v1.get()) text_entry.pack() w = Label(root, text="V2") w.pack() text_entry = Entry(root, textvariable = v2.get()) text_entry.pack() w = Label(root, text="V3") w.pack() text_entry = Entry(root, textvariable = v3.get()) text_entry.pack() # Add a 'Run' button b = Button(root, text="Run fuction", command= system_call(Command call, command(v1, v2,v3))) b.pack() # Call the GUI root.mainloop()
Getting an error which states that string objects and instance objects cannot be catted.