490 """ |
490 """ |
491 Private slot to copy the current script as 'main.py' onto the |
491 Private slot to copy the current script as 'main.py' onto the |
492 connected device. |
492 connected device. |
493 """ |
493 """ |
494 aw = ericApp().getObject("ViewManager").activeWindow() |
494 aw = ericApp().getObject("ViewManager").activeWindow() |
495 if not aw: |
495 if aw: |
496 return |
496 title = self.tr("Save Script as 'main.py'") |
497 |
497 |
498 title = self.tr("Save Script as 'main.py'") |
498 if not (aw.isPyFile() or aw.isMicroPythonFile()): |
499 |
499 yes = EricMessageBox.yesNo( |
500 if not (aw.isPyFile() or aw.isMicroPythonFile()): |
500 self.microPython, |
501 yes = EricMessageBox.yesNo( |
501 title, |
502 self.microPython, |
502 self.tr( |
503 title, |
503 """The current editor does not contain a Python""" |
504 self.tr( |
504 """ script. Write it anyway?""" |
505 """The current editor does not contain a Python""" |
505 ), |
506 """ script. Write it anyway?""" |
506 ) |
507 ), |
507 if not yes: |
508 ) |
508 return |
509 if not yes: |
509 |
|
510 script = aw.text().strip() |
|
511 if not script: |
|
512 EricMessageBox.warning( |
|
513 self.microPython, |
|
514 title, |
|
515 self.tr("""The script is empty. Aborting."""), |
|
516 ) |
510 return |
517 return |
511 |
518 |
512 script = aw.text().strip() |
519 self.putData("main.py", script.encode("utf-8")) |
513 if not script: |
520 |
514 EricMessageBox.warning( |
521 # reset the device |
515 self.microPython, title, self.tr("""The script is empty. Aborting.""") |
522 self.__resetDevice() |
516 ) |
|
517 return |
|
518 |
|
519 self.putData("main.py", script.encode("utf-8")) |
|
520 |
|
521 # reset the device |
|
522 self.__resetDevice() |
|
523 |
523 |
524 @pyqtSlot() |
524 @pyqtSlot() |
525 def __resetDevice(self): |
525 def __resetDevice(self): |
526 """ |
526 """ |
527 Private slot to reset the connected device. |
527 Private slot to reset the connected device. |