eric6/MicroPython/CircuitPythonFirmwareSelectionDialog.py

changeset 7595
5db6bfeff23e
parent 7360
9190402e4505
child 7596
1b1f401e1d70
equal deleted inserted replaced
7594:ee35df230130 7595:5db6bfeff23e
46 self.tr("CircuitPython Firmware Files (*.uf2);;" 46 self.tr("CircuitPython Firmware Files (*.uf2);;"
47 "All Files (*)")) 47 "All Files (*)"))
48 48
49 self.bootPicker.setMode(E5PathPickerModes.DirectoryShowFilesMode) 49 self.bootPicker.setMode(E5PathPickerModes.DirectoryShowFilesMode)
50 50
51 self.__manualMarker = "<manual>"
51 boards = ( 52 boards = (
52 ("", ""), # indicator for no selection 53 ("", ""), # indicator for no selection
53 54
54 ("Circuit Playground Express", "CPLAYBOOT"), 55 ("Circuit Playground Express", "CPLAYBOOT"),
55 ("Feather M0 Express", "FEATHERBOOT"), 56 ("Feather M0 Express", "FEATHERBOOT"),
61 ("Metro M0 Express", "METROBOOT"), 62 ("Metro M0 Express", "METROBOOT"),
62 ("Metro M4 Express", "METROM4BOOT"), 63 ("Metro M4 Express", "METROM4BOOT"),
63 ("NeoTrelis M4 Express", "TRELM4BOOT"), 64 ("NeoTrelis M4 Express", "TRELM4BOOT"),
64 ("Trinket M0", "TRINKETBOOT"), 65 ("Trinket M0", "TRINKETBOOT"),
65 66
66 ("Manual Select", "<manual>"), 67 (self.tr("Manual Select"), self.__manualMarker),
67 ) 68 )
68 for boardName, bootVolume in boards: 69 for boardName, bootVolume in boards:
69 self.boardComboBox.addItem(boardName, bootVolume) 70 self.boardComboBox.addItem(boardName, bootVolume)
70 71
71 msh = self.minimumSizeHint() 72 msh = self.minimumSizeHint()
82 83
83 if not bool(firmwareFile) or not os.path.exists(firmwareFile): 84 if not bool(firmwareFile) or not os.path.exists(firmwareFile):
84 enable = False 85 enable = False
85 else: 86 else:
86 volumeName = self.boardComboBox.currentData() 87 volumeName = self.boardComboBox.currentData()
87 if volumeName and volumeName != "<manual>": 88 if volumeName and volumeName != self.__manualMarker:
88 # check if the user selected a board and the board is in 89 # check if the user selected a board and the board is in
89 # bootloader mode 90 # bootloader mode
90 deviceDirectory = Utilities.findVolume(volumeName) 91 deviceDirectory = Utilities.findVolume(volumeName)
91 if deviceDirectory: 92 if deviceDirectory:
92 self.bootPicker.setText(deviceDirectory) 93 self.bootPicker.setText(deviceDirectory)
102 """ select the "Manual Select" entry and""" 103 """ select the "Manual Select" entry and"""
103 """ enter the path to the device below.</p>""") 104 """ enter the path to the device below.</p>""")
104 .format(volumeName) 105 .format(volumeName)
105 ) 106 )
106 107
107 elif volumeName == "<manual>": 108 elif volumeName == self.__manualMarker:
108 # select the device path manually 109 # select the device path manually
109 deviceDirectory = self.bootPicker.text() 110 deviceDirectory = self.bootPicker.text()
110 enable = (bool(deviceDirectory) and 111 enable = (bool(deviceDirectory) and
111 os.path.exists(deviceDirectory)) 112 os.path.exists(deviceDirectory))
112 113
132 Private slot to handle the selection of a board type. 133 Private slot to handle the selection of a board type.
133 134
134 @param index index of the selected board type 135 @param index index of the selected board type
135 @type int 136 @type int
136 """ 137 """
137 if self.boardComboBox.itemData(index) == "<manual>": 138 if self.boardComboBox.itemData(index) == self.__manualMarker:
138 self.bootPicker.clear() 139 self.bootPicker.clear()
139 self.bootPicker.setEnabled(True) 140 self.bootPicker.setEnabled(True)
140 else: 141 else:
141 self.bootPicker.setEnabled(False) 142 self.bootPicker.setEnabled(False)
142 143

eric ide

mercurial