#!/usr/bin/env python from tkinter import * from tkinter import filedialog from tkinter.messagebox import * import subprocess file = None def Install(): ip = e.get() print ("Installing ",file) print ("At ip ", ip) if file != None: subprocess.call(["python", "espota.py", "-i", ip, "-f", file]) else: showerror("Error", "Select a firmware first") def askopenfile(): global file file = filedialog.askopenfilename(title='Select Firmware', filetypes=[('binaries', '*.bin')]) root = Tk() root.title("Firmware Updater") button_opt = {'fill': constants.BOTH, 'padx': 5, 'pady': 5} Button(root, text='Select firmware', command=askopenfile).pack(**button_opt) e = Entry(root) e.pack() e.delete(0, END) e.insert(0, "192.168.0.XX") Button(root, text = 'Install', command = Install).pack(pady=20) root.mainloop()