#!/usr/bin/env python # Gui to get parameters for espota.py # espota.py is available https://raw.githubusercontent.com/esp8266/Arduino/master/tools/espota.py # and should be in the same directory from tkinter import * from tkinter import filedialog from tkinter.messagebox import * import subprocess class Updater(Frame): file = None def __init__(self, win, **kwargs): Frame.__init__(self, win, **kwargs) button_opt = {'fill': constants.BOTH, 'padx': 5, 'pady': 5} Button(root, text='Select firmware', command=self.askopenfile).pack(**button_opt) self.ipEntry = Entry(root) self.ipEntry.pack() self.ipEntry.delete(0, END) self.ipEntry.insert(0, "192.168.0.XX") Button(root, text='Install', command=self.install).pack(pady=20) def install(self): ip = self.ipEntry.get() print("Installing", self.file, "at ip", ip) if self.file != None: subprocess.call(["python", "espota.py", "-i", ip, "-f", self.file]) else: showerror("Error", "Select a firmware first") def askopenfile(self): self.file = filedialog.askopenfilename( title='Select Firmware', filetypes=[('binaries', '*.bin')]) root = Tk() root.title("Firmware Updater") updater = Updater(root) updater.mainloop() updater.destroy()