My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

upload_prompt_extra_script.py 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #
  2. # upload_prompt_extra_script.py
  3. # set the output_port
  4. #
  5. from __future__ import print_function
  6. has_tkinter = False
  7. try:
  8. import sys
  9. if sys.version_info[0] < 3:
  10. import Tkinter as tk
  11. import tkFileDialog as fileDialog
  12. from Tkinter import Tk
  13. else:
  14. import tkinter as tk
  15. from tkinter import Tk
  16. from tkinter import filedialog as fileDialog
  17. has_tkinter = True
  18. except:
  19. pass
  20. import pioutil
  21. if has_tkinter and pioutil.is_pio_build():
  22. Import("env")
  23. def print_error(e):
  24. print('\nUnable to find destination disk (%s)\n' %( e ) )
  25. def before_upload(source, target, env):
  26. #
  27. # Find a disk for upload
  28. #
  29. upload_disk = ''
  30. root = Tk() # pointing root to Tk() to use it as Tk() in program.
  31. root.withdraw() # Hides small tkinter window.
  32. root.attributes('-topmost', True) # Opened windows will be active. above all windows despite of selection.
  33. upload_disk = fileDialog.askdirectory(title="Select the root of your SDCARD") # Returns opened path as str
  34. if not upload_disk:
  35. print_error('Canceled')
  36. return
  37. else:
  38. env.Replace(
  39. UPLOAD_FLAGS="-P$UPLOAD_PORT"
  40. )
  41. env.Replace(UPLOAD_PORT=upload_disk)
  42. print('\nUpload disk: ', upload_disk, '\n')
  43. env.AddPreAction("upload", before_upload)