eric6/Plugins/PluginWizardQFileDialog.py

branch
maintenance
changeset 8273
698ae46f40a4
parent 8176
31965986ecd1
parent 8218
7c09585bd960
equal deleted inserted replaced
8190:fb0ef164f536 8273:698ae46f40a4
42 """ 42 """
43 Constructor 43 Constructor
44 44
45 @param ui reference to the user interface object (UI.UserInterface) 45 @param ui reference to the user interface object (UI.UserInterface)
46 """ 46 """
47 super(FileDialogWizard, self).__init__(ui) 47 super().__init__(ui)
48 self.__ui = ui 48 self.__ui = ui
49 49
50 # PyQt5 50 # PyQt5
51 self.__pyqtRe = re.compile(r"(?:import|from)\s+PyQt([56])") 51 self.__pyqtRe = re.compile(r"(?:import|from)\s+PyQt([56])")
52 52
157 E5MessageBox.critical( 157 E5MessageBox.critical(
158 self.__ui, 158 self.__ui,
159 self.tr('No current editor'), 159 self.tr('No current editor'),
160 self.tr('Please open or create a file first.')) 160 self.tr('Please open or create a file first.'))
161 else: 161 else:
162 if variant not in ("QFileDialog", "E5FileDialog"):
163 raise ValueError("Illegal dialog variant given")
164
162 if variant == "QFileDialog": 165 if variant == "QFileDialog":
163 match = self.__pyqtRe.search(editor.text()) 166 match = self.__pyqtRe.search(editor.text())
164 if match is None: 167 if match is None:
165 # unknown 168 # unknown
166 dialogVariant = 0 169 dialogVariant = 0
167 else: 170 else:
168 # PyQt5/PyQt6 171 # PyQt5/PyQt6
169 dialogVariant = int(match.group(1)) 172 dialogVariant = int(match.group(1))
170 elif variant == "E5FileDialog": 173 else:
171 # E5FileDialog 174 # E5FileDialog
172 dialogVariant = -1 175 dialogVariant = -1
173 else:
174 raise ValueError("Illegal dialog variant given")
175 176
176 code, ok = self.__callForm(editor, dialogVariant) 177 code, ok = self.__callForm(editor, dialogVariant)
177 if ok: 178 if ok:
178 line, index = editor.getCursorPosition() 179 line, index = editor.getCursorPosition()
179 # It should be done on this way to allow undo 180 # It should be done on this way to allow undo

eric ide

mercurial