src/eric7/MicroPython/MicroPythonWidget.py

branch
mpy_network
changeset 9787
163511257f24
parent 9776
210bf87ae5c7
child 9799
a79430a8811d
equal deleted inserted replaced
9783:5f84d5eeee9e 9787:163511257f24
221 self.setupUi(self) 221 self.setupUi(self)
222 222
223 self.layout().setContentsMargins(0, 3, 0, 0) 223 self.layout().setContentsMargins(0, 3, 0, 0)
224 224
225 self.__ui = parent 225 self.__ui = parent
226
226 self.__wifiController = WifiController(self, self) 227 self.__wifiController = WifiController(self, self)
228 self.__wifiMenu = None
227 229
228 self.__superMenu = QMenu(self) 230 self.__superMenu = QMenu(self)
229 self.__superMenu.aboutToShow.connect(self.__aboutToShowSuperMenu) 231 self.__superMenu.aboutToShow.connect(self.__aboutToShowSuperMenu)
230 232
231 self.menuButton.setObjectName("micropython_supermenu_button") 233 self.menuButton.setObjectName("micropython_supermenu_button")
616 else: 618 else:
617 self.connectButton.setIcon(EricPixmapCache.getIcon("linkConnect")) 619 self.connectButton.setIcon(EricPixmapCache.getIcon("linkConnect"))
618 self.connectButton.setToolTip( 620 self.connectButton.setToolTip(
619 self.tr("Press to connect the selected device") 621 self.tr("Press to connect the selected device")
620 ) 622 )
623
624 if not connected and self.__wifiMenu and self.__wifiMenu.isTearOffMenuVisible():
625 self.__wifiMenu.hideTearOffMenu()
621 626
622 def isConnected(self): 627 def isConnected(self):
623 """ 628 """
624 Public method to get the MicroPython device connection state. 629 Public method to get the MicroPython device connection state.
625 630
1447 else: 1452 else:
1448 downloadMenu = None 1453 downloadMenu = None
1449 1454
1450 # prepare the WiFi menu 1455 # prepare the WiFi menu
1451 if self.__device and self.__connected and self.__device.getDeviceData("wifi"): 1456 if self.__device and self.__connected and self.__device.getDeviceData("wifi"):
1452 wifiMenu = self.__wifiController.createMenu(self.__superMenu) 1457 if self.__wifiMenu is not None:
1453 else: 1458 self.__wifiMenu.deleteLater()
1454 wifiMenu = None 1459 self.__wifiMenu = self.__wifiController.createMenu(self.__superMenu)
1460 else:
1461 self.__wifiMenu = None
1455 1462
1456 # populate the super menu 1463 # populate the super menu
1457 hasTime = self.__device.hasTimeCommands() if self.__device else False 1464 hasTime = self.__device.hasTimeCommands() if self.__device else False
1458 1465
1459 self.__superMenu.addAction( 1466 self.__superMenu.addAction(
1494 ).setEnabled(available and bool(aw)) 1501 ).setEnabled(available and bool(aw))
1495 self.__superMenu.addSeparator() 1502 self.__superMenu.addSeparator()
1496 if self.__device: 1503 if self.__device:
1497 self.__device.addDeviceMenuEntries(self.__superMenu) 1504 self.__device.addDeviceMenuEntries(self.__superMenu)
1498 self.__superMenu.addSeparator() 1505 self.__superMenu.addSeparator()
1499 if wifiMenu is not None: 1506 if self.__wifiMenu is not None:
1500 self.__superMenu.addMenu(wifiMenu) 1507 self.__superMenu.addMenu(self.__wifiMenu)
1501 self.__superMenu.addSeparator() 1508 self.__superMenu.addSeparator()
1502 if downloadMenu is None: 1509 if downloadMenu is None:
1503 # generic download action 1510 # generic download action
1504 self.__superMenu.addAction( 1511 self.__superMenu.addAction(
1505 self.tr("Download Firmware"), self.__downloadFirmware 1512 self.tr("Download Firmware"), self.__downloadFirmware
1604 boardInfo = self.__device.getBoardInformation() 1611 boardInfo = self.__device.getBoardInformation()
1605 1612
1606 dlg = BoardDataDialog(boardInfo) 1613 dlg = BoardDataDialog(boardInfo)
1607 dlg.exec() 1614 dlg.exec()
1608 except Exception as exc: 1615 except Exception as exc:
1609 self.__showError("getBoardInformation()", str(exc)) 1616 self.showError("getBoardInformation()", str(exc))
1610 1617
1611 @pyqtSlot() 1618 @pyqtSlot()
1612 def __synchronizeTime(self, quiet=False): 1619 def __synchronizeTime(self, quiet=False):
1613 """ 1620 """
1614 Private slot to set the time of the connected device to the local 1621 Private slot to set the time of the connected device to the local
1634 " synchronized with the local time.</p>" 1641 " synchronized with the local time.</p>"
1635 ) 1642 )
1636 + self.__getDeviceTime(), 1643 + self.__getDeviceTime(),
1637 ) 1644 )
1638 except Exception as exc: 1645 except Exception as exc:
1639 self.__showError("syncTime()", str(exc)) 1646 self.showError("syncTime()", str(exc))
1640 1647
1641 def __getDeviceTime(self): 1648 def __getDeviceTime(self):
1642 """ 1649 """
1643 Private method to get a string containing the date and time of the 1650 Private method to get a string containing the date and time of the
1644 connected device. 1651 connected device.
1661 except ValueError: 1668 except ValueError:
1662 return self.tr("<h3>Device Date and Time</h3><p>{0}</p>").format( 1669 return self.tr("<h3>Device Date and Time</h3><p>{0}</p>").format(
1663 dateTimeString.strip() 1670 dateTimeString.strip()
1664 ) 1671 )
1665 except Exception as exc: 1672 except Exception as exc:
1666 self.__showError("getTime()", str(exc)) 1673 self.showError("getTime()", str(exc))
1667 return "" 1674 return ""
1668 else: 1675 else:
1669 return "" 1676 return ""
1670 1677
1671 @pyqtSlot() 1678 @pyqtSlot()
1738 "<td align='center'>{2}</td></tr>" 1745 "<td align='center'>{2}</td></tr>"
1739 "</table>" 1746 "</table>"
1740 ).format(localdate, localtime, deviceDateTimeString.strip()), 1747 ).format(localdate, localtime, deviceDateTimeString.strip()),
1741 ) 1748 )
1742 except Exception as exc: 1749 except Exception as exc:
1743 self.__showError("getTime()", str(exc)) 1750 self.showError("getTime()", str(exc))
1744 1751
1745 def __showError(self, method, error): 1752 def showError(self, method, error):
1746 """ 1753 """
1747 Private method to show some error message. 1754 Public method to show some error message.
1748 1755
1749 @param method name of the method the error occured in 1756 @param method name of the method the error occured in
1750 @type str 1757 @type str
1751 @param error error message 1758 @param error error message
1752 @type str 1759 @type str
2005 info=self.tr("Plus any modules on the filesystem."), 2012 info=self.tr("Plus any modules on the filesystem."),
2006 parent=self, 2013 parent=self,
2007 ) 2014 )
2008 dlg.show() 2015 dlg.show()
2009 except Exception as exc: 2016 except Exception as exc:
2010 self.__showError("getModules()", str(exc)) 2017 self.showError("getModules()", str(exc))

eric ide

mercurial