#!/usr/bin/env python3
import shlex
from tkinter import *
from tkinter import messagebox
from psutil import Popen


top = Tk()
top.title("Franka Gripper Control")
top.geometry("300x75")

def open(): 
	node_process = Popen(shlex.split('rosrun franka_interactive_controllers libfranka_gripper_run 1'))
	messagebox.showinfo("Open Gripper", "Gripper Opened")
	node_process.terminate()

def close():   
	node_process = Popen(shlex.split('rosrun franka_interactive_controllers libfranka_gripper_run 0'))
	messagebox.showinfo("Close Gripper", "Gripper Closed")
	node_process.terminate()

B1 = Button(top, text = "Open Gripper", command = open)
B1.place(x = 30,y = 20)

B2 = Button(top, text = "Close Gripper", command = close)
B2.place(x = 160,y = 20)


top.mainloop()

[((14, 1, 14, 54), 'tkinter.messagebox.showinfo', 'messagebox.showinfo', ({(14, 21, 14, 35): '"""Open Gripper"""', (14, 37, 14, 53): '"""Gripper Opened"""'}, {}), "('Open Gripper', 'Gripper Opened')", False, 'from tkinter import messagebox\n'), ((19, 1, 19, 55), 'tkinter.messagebox.showinfo', 'messagebox.showinfo', ({(19, 21, 19, 36): '"""Close Gripper"""', (19, 38, 19, 54): '"""Gripper Closed"""'}, {}), "('Close Gripper', 'Gripper Closed')", False, 'from tkinter import messagebox\n'), ((13, 22, 13, 98), 'shlex.split', 'shlex.split', ({(13, 34, 13, 97): '"""rosrun franka_interactive_controllers libfranka_gripper_run 1"""'}, {}), "('rosrun franka_interactive_controllers libfranka_gripper_run 1')", False, 'import shlex\n'), ((18, 22, 18, 98), 'shlex.split', 'shlex.split', ({(18, 34, 18, 97): '"""rosrun franka_interactive_controllers libfranka_gripper_run 0"""'}, {}), "('rosrun franka_interactive_controllers libfranka_gripper_run 0')", False, 'import shlex\n')]