src/eric7/MicroPython/RP2040Devices.py

branch
eric7
changeset 9752
2b9546c0cbd9
parent 9751
606ac0e26533
child 9755
1a09700229e7
equal deleted inserted replaced
9751:606ac0e26533 9752:2b9546c0cbd9
8 (e.g. Raspberry Pi Pico). 8 (e.g. Raspberry Pi Pico).
9 """ 9 """
10 10
11 from PyQt6.QtCore import QUrl, pyqtSlot 11 from PyQt6.QtCore import QUrl, pyqtSlot
12 from PyQt6.QtNetwork import QNetworkRequest 12 from PyQt6.QtNetwork import QNetworkRequest
13 from PyQt6.QtWidgets import QMenu
13 14
14 from eric7 import Globals, Preferences 15 from eric7 import Globals, Preferences
15 from eric7.EricWidgets import EricMessageBox 16 from eric7.EricWidgets import EricMessageBox
16 from eric7.EricWidgets.EricApplication import ericApp 17 from eric7.EricWidgets.EricApplication import ericApp
17 18
35 @param parent reference to the parent object 36 @param parent reference to the parent object
36 @type QObject 37 @type QObject
37 """ 38 """
38 super().__init__(microPythonWidget, deviceType, parent) 39 super().__init__(microPythonWidget, deviceType, parent)
39 40
41 self.__createRP2040Menu()
42
40 def setButtons(self): 43 def setButtons(self):
41 """ 44 """
42 Public method to enable the supported action buttons. 45 Public method to enable the supported action buttons.
43 """ 46 """
44 super().setButtons() 47 super().setButtons()
113 File Manager and a reason why it cannot. 116 File Manager and a reason why it cannot.
114 @rtype tuple of (bool, str) 117 @rtype tuple of (bool, str)
115 """ 118 """
116 return True, "" 119 return True, ""
117 120
121 def __createRP2040Menu(self):
122 """
123 Private method to create the microbit submenu.
124 """
125 self.__rp2040Menu = QMenu(self.tr("RP2040 Functions"))
126
127 self.__showMpyAct = self.__rp2040Menu.addAction(
128 self.tr("Show MicroPython Versions"), self.__showFirmwareVersions
129 )
130 self.__rp2040Menu.addSeparator()
131 self.__bootloaderAct = self.__rp2040Menu.addAction(
132 self.tr("Activate Bootloader"), self.__activateBootloader
133 )
134 self.__flashMpyAct = self.__rp2040Menu.addAction(
135 self.tr("Flash MicroPython Firmware"), self.__flashPython
136 )
137
118 def addDeviceMenuEntries(self, menu): 138 def addDeviceMenuEntries(self, menu):
119 """ 139 """
120 Public method to add device specific entries to the given menu. 140 Public method to add device specific entries to the given menu.
121 141
122 @param menu reference to the context menu 142 @param menu reference to the context menu
123 @type QMenu 143 @type QMenu
124 """ 144 """
125 connected = self.microPython.isConnected() 145 connected = self.microPython.isConnected()
126 linkConnected = self.microPython.isLinkConnected() 146 linkConnected = self.microPython.isLinkConnected()
127 147
128 menu.addAction( 148 self.__showMpyAct.setEnabled(connected)
129 self.tr("Show MicroPython Versions"), self.__showFirmwareVersions 149 self.__bootloaderAct.setEnabled(connected)
130 ).setEnabled(connected) 150 self.__flashMpyAct.setEnabled(not linkConnected)
131 menu.addAction( 151
132 self.tr("Activate Bootloader"), self.__activateBootloader 152 menu.addMenu(self.__rp2040Menu)
133 ).setEnabled(connected)
134 menu.addAction(
135 self.tr("Flash MicroPython Firmware"), self.__flashPython
136 ).setEnabled(not linkConnected)
137 153
138 def hasFlashMenuEntry(self): 154 def hasFlashMenuEntry(self):
139 """ 155 """
140 Public method to check, if the device has its own flash menu entry. 156 Public method to check, if the device has its own flash menu entry.
141 157

eric ide

mercurial