Plugins/WizardPlugins/QRegExpWizard/QRegExpWizardDialog.py

changeset 12
1d8dd9706f46
parent 0
de9c2efb9d02
child 13
1af94a91f439
equal deleted inserted replaced
11:b0996e4a289e 12:1d8dd9706f46
13 from PyQt4.QtCore import * 13 from PyQt4.QtCore import *
14 from PyQt4.QtGui import * 14 from PyQt4.QtGui import *
15 15
16 from E4Gui.E4Application import e4App 16 from E4Gui.E4Application import e4App
17 17
18 from Ui_QRegExpWizardDialog import Ui_QRegExpWizardDialog 18 from .Ui_QRegExpWizardDialog import Ui_QRegExpWizardDialog
19 19
20 from QRegExpWizardRepeatDialog import QRegExpWizardRepeatDialog 20 from .QRegExpWizardRepeatDialog import QRegExpWizardRepeatDialog
21 from QRegExpWizardCharactersDialog import QRegExpWizardCharactersDialog 21 from .QRegExpWizardCharactersDialog import QRegExpWizardCharactersDialog
22 22
23 import UI.PixmapCache 23 import UI.PixmapCache
24 24
25 import Utilities 25 import Utilities
26 26
237 QMessageBox.Abort) 237 QMessageBox.Abort)
238 if res == QMessageBox.Abort or res == QMessageBox.Cancel: 238 if res == QMessageBox.Abort or res == QMessageBox.Cancel:
239 return 239 return
240 240
241 try: 241 try:
242 f=open(Utilities.toNativeSeparators(fname), "wb") 242 f=open(Utilities.toNativeSeparators(fname), "w")
243 f.write(self.regexpLineEdit.text()) 243 f.write(self.regexpLineEdit.text())
244 f.close() 244 f.close()
245 except IOError, err: 245 except IOError as err:
246 QMessageBox.information(self, 246 QMessageBox.information(self,
247 self.trUtf8("Save regular expression"), 247 self.trUtf8("Save regular expression"),
248 self.trUtf8("""<p>The regular expression could not be saved.</p>""" 248 self.trUtf8("""<p>The regular expression could not be saved.</p>"""
249 """<p>Reason: {0}</p>""").format(unicode(err))) 249 """<p>Reason: {0}</p>""").format(str(err)))
250 250
251 @pyqtSlot() 251 @pyqtSlot()
252 def on_loadButton_clicked(self): 252 def on_loadButton_clicked(self):
253 """ 253 """
254 Private slot to load a regexp from a file. 254 Private slot to load a regexp from a file.
258 self.trUtf8("Load regular expression"), 258 self.trUtf8("Load regular expression"),
259 "", 259 "",
260 self.trUtf8("RegExp Files (*.rx);;All Files (*)")) 260 self.trUtf8("RegExp Files (*.rx);;All Files (*)"))
261 if fname: 261 if fname:
262 try: 262 try:
263 f=open(Utilities.toNativeSeparators(fname), "rb") 263 f=open(Utilities.toNativeSeparators(fname), "r")
264 regexp = f.read() 264 regexp = f.read()
265 f.close() 265 f.close()
266 self.regexpLineEdit.setText(regexp) 266 self.regexpLineEdit.setText(regexp)
267 except IOError, err: 267 except IOError as err:
268 QMessageBox.information(self, 268 QMessageBox.information(self,
269 self.trUtf8("Save regular expression"), 269 self.trUtf8("Save regular expression"),
270 self.trUtf8("""<p>The regular expression could not be saved.</p>""" 270 self.trUtf8("""<p>The regular expression could not be saved.</p>"""
271 """<p>Reason: {0}</p>""").format(unicode(err))) 271 """<p>Reason: {0}</p>""").format(str(err)))
272 272
273 @pyqtSlot() 273 @pyqtSlot()
274 def on_copyButton_clicked(self): 274 def on_copyButton_clicked(self):
275 """ 275 """
276 Private slot to copy the regexp string into the clipboard. 276 Private slot to copy the regexp string into the clipboard.

eric ide

mercurial