Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardDialog.py

changeset 564
b3d966393ba9
parent 553
5af61623ae3c
child 791
9ec2ac20e54e
equal deleted inserted replaced
563:e35d2cda9a74 564:b3d966393ba9
74 self.buttonBox.addButton(self.trUtf8("Execute"), QDialogButtonBox.ActionRole) 74 self.buttonBox.addButton(self.trUtf8("Execute"), QDialogButtonBox.ActionRole)
75 self.executeButton.setToolTip(self.trUtf8("Execute the regular expression")) 75 self.executeButton.setToolTip(self.trUtf8("Execute the regular expression"))
76 self.nextButton = \ 76 self.nextButton = \
77 self.buttonBox.addButton(self.trUtf8("Next match"), 77 self.buttonBox.addButton(self.trUtf8("Next match"),
78 QDialogButtonBox.ActionRole) 78 QDialogButtonBox.ActionRole)
79 self.nextButton.setToolTip(\ 79 self.nextButton.setToolTip(
80 self.trUtf8("Show the next match of the regular expression")) 80 self.trUtf8("Show the next match of the regular expression"))
81 self.nextButton.setEnabled(False) 81 self.nextButton.setEnabled(False)
82 82
83 if fromEric: 83 if fromEric:
84 self.buttonBox.button(QDialogButtonBox.Close).hide() 84 self.buttonBox.button(QDialogButtonBox.Close).hide()
85 self.copyButton = None 85 self.copyButton = None
86 else: 86 else:
87 self.copyButton = \ 87 self.copyButton = \
88 self.buttonBox.addButton(self.trUtf8("Copy"), QDialogButtonBox.ActionRole) 88 self.buttonBox.addButton(self.trUtf8("Copy"), QDialogButtonBox.ActionRole)
89 self.copyButton.setToolTip(\ 89 self.copyButton.setToolTip(
90 self.trUtf8("Copy the regular expression to the clipboard")) 90 self.trUtf8("Copy the regular expression to the clipboard"))
91 self.buttonBox.button(QDialogButtonBox.Ok).hide() 91 self.buttonBox.button(QDialogButtonBox.Ok).hide()
92 self.buttonBox.button(QDialogButtonBox.Cancel).hide() 92 self.buttonBox.button(QDialogButtonBox.Cancel).hide()
93 self.variableLabel.hide() 93 self.variableLabel.hide()
94 self.variableLineEdit.hide() 94 self.variableLineEdit.hide()
167 E5MessageBox.information(self, 167 E5MessageBox.information(self,
168 self.trUtf8("Named reference"), 168 self.trUtf8("Named reference"),
169 self.trUtf8("""No named groups have been defined yet.""")) 169 self.trUtf8("""No named groups have been defined yet."""))
170 return 170 return
171 171
172 groupName, ok = QInputDialog.getItem(\ 172 groupName, ok = QInputDialog.getItem(
173 self, 173 self,
174 self.trUtf8("Named reference"), 174 self.trUtf8("Named reference"),
175 self.trUtf8("Select group name:"), 175 self.trUtf8("Select group name:"),
176 names, 176 names,
177 0, True) 177 0, True)
295 @pyqtSlot() 295 @pyqtSlot()
296 def on_saveButton_clicked(self): 296 def on_saveButton_clicked(self):
297 """ 297 """
298 Private slot to save the regexp to a file. 298 Private slot to save the regexp to a file.
299 """ 299 """
300 fname, selectedFilter = QFileDialog.getSaveFileNameAndFilter(\ 300 fname, selectedFilter = QFileDialog.getSaveFileNameAndFilter(
301 self, 301 self,
302 self.trUtf8("Save regular expression"), 302 self.trUtf8("Save regular expression"),
303 "", 303 "",
304 self.trUtf8("RegExp Files (*.rx);;All Files (*)"), 304 self.trUtf8("RegExp Files (*.rx);;All Files (*)"),
305 None, 305 None,
332 @pyqtSlot() 332 @pyqtSlot()
333 def on_loadButton_clicked(self): 333 def on_loadButton_clicked(self):
334 """ 334 """
335 Private slot to load a regexp from a file. 335 Private slot to load a regexp from a file.
336 """ 336 """
337 fname = QFileDialog.getOpenFileName(\ 337 fname = QFileDialog.getOpenFileName(
338 self, 338 self,
339 self.trUtf8("Load regular expression"), 339 self.trUtf8("Load regular expression"),
340 "", 340 "",
341 self.trUtf8("RegExp Files (*.rx);;All Files (*)")) 341 self.trUtf8("RegExp Files (*.rx);;All Files (*)"))
342 if fname: 342 if fname:
388 self.multilineCheckBox.isChecked() and re.MULTILINE or 0 | \ 388 self.multilineCheckBox.isChecked() and re.MULTILINE or 0 | \
389 self.dotallCheckBox.isChecked() and re.DOTALL or 0 | \ 389 self.dotallCheckBox.isChecked() and re.DOTALL or 0 | \
390 self.verboseCheckBox.isChecked() and re.VERBOSE or 0 | \ 390 self.verboseCheckBox.isChecked() and re.VERBOSE or 0 | \
391 (not self.unicodeCheckBox.isChecked() and re.UNICODE or 0)) 391 (not self.unicodeCheckBox.isChecked() and re.UNICODE or 0))
392 E5MessageBox.information(self, 392 E5MessageBox.information(self,
393 self.trUtf8(""), 393 self.trUtf8("Validation"),
394 self.trUtf8("""The regular expression is valid.""")) 394 self.trUtf8("""The regular expression is valid."""))
395 except re.error as e: 395 except re.error as e:
396 E5MessageBox.critical(self, 396 E5MessageBox.critical(self,
397 self.trUtf8("Error"), 397 self.trUtf8("Error"),
398 self.trUtf8("""Invalid regular expression: {0}""") 398 self.trUtf8("""Invalid regular expression: {0}""")

eric ide

mercurial