V1.0.3
This commit is contained in:
+17
-11
@@ -5,6 +5,9 @@ import tkinter as tk
|
||||
from tkinter import ttk
|
||||
from tkinter import filedialog, messagebox
|
||||
import serial.tools.list_ports
|
||||
import sys
|
||||
from mpremote.main import main as mpremote_main
|
||||
|
||||
|
||||
|
||||
class RP2040UploaderApp:
|
||||
@@ -13,7 +16,6 @@ class RP2040UploaderApp:
|
||||
|
||||
self.folder_path = os.path.join(os.getcwd(), "Resources/RP2040")
|
||||
self.config_path = os.path.join(self.folder_path, "config.json")
|
||||
self.mpremote_path = os.path.join(os.getcwd(), "Resources", "mpremote.exe")
|
||||
|
||||
|
||||
self.label = tk.Label(master, text="Searching for RP2040...")
|
||||
@@ -94,27 +96,31 @@ class RP2040UploaderApp:
|
||||
if os.path.isfile(full_path):
|
||||
self.label.config(text=f"Uploading {filename}...")
|
||||
self.master.update()
|
||||
result = subprocess.run(
|
||||
[self.mpremote_path, "connect", self.port, "fs", "cp", full_path, f":{filename}"],
|
||||
capture_output=True,
|
||||
text=True
|
||||
)
|
||||
|
||||
if result.returncode != 0:
|
||||
# Save original sys.argv and replace it with mpremote-style args
|
||||
original_argv = sys.argv
|
||||
sys.argv = ["mpremote", "connect", self.port, "fs", "cp", full_path, f":{filename}"]
|
||||
|
||||
try:
|
||||
mpremote_main()
|
||||
except SystemExit as e:
|
||||
success = False
|
||||
messagebox.showerror("Upload Failed", f"Failed to upload {filename}:\n{result.stderr}")
|
||||
messagebox.showerror("Upload Failed", f"Failed to upload {filename} (mpremote exited with code {e.code}).")
|
||||
break
|
||||
finally:
|
||||
sys.argv = original_argv # Always restore original argv
|
||||
|
||||
if success:
|
||||
self.label.config(text=f"DONE")
|
||||
self.label.config(text="DONE")
|
||||
self.master.update()
|
||||
messagebox.showinfo("Success", "All files uploaded successfully!")
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
root = tk.Tk()
|
||||
app = RP2040UploaderApp(root)
|
||||
root.title("RP2040 Loader V1.0.1")
|
||||
root.title("RP2040 Loader V1.0.2")
|
||||
|
||||
root.iconbitmap(r'Resources/icon1.ico')
|
||||
|
||||
@@ -129,7 +135,7 @@ if __name__ == "__main__":
|
||||
# Footer label in bottom right
|
||||
footer_frame = tk.Frame(root)
|
||||
footer_frame.pack(side=tk.BOTTOM, fill=tk.X)
|
||||
footer_label = tk.Label(footer_frame, text="Made by Hendo 22/07/2025", anchor="e", justify="right", font=("TkDefaultFont", 7, "bold"))
|
||||
footer_label = tk.Label(footer_frame, text="Made by Hendo 23/07/2025", anchor="e", justify="right", font=("TkDefaultFont", 7, "bold"))
|
||||
footer_label.pack(side=tk.RIGHT, padx=10, pady=5)
|
||||
|
||||
root.mainloop()
|
||||
|
||||
Reference in New Issue
Block a user