def translate(self): res = Lookup.look_up(self.lineEdit.text()) if not res: htmlfile = open("./template/404.html", 'r') self.textEdit.setText(self.tr(htmlfile.read())) htmlfile.close() else: reload(sys) sys.setdefaultencoding('utf-8') res = unicode(res) self.textEdit.setText(res)
def Translate(self): myClipBoard = QtGui.QApplication.clipboard() word = myClipBoard.text("plain", QtGui.QClipboard.Selection) result = Lookup.look_up(word) if not result: htmlfile = open("./template/404.html", 'r') self.textedit.setText(self.tr(htmlfile.read())) htmlfile.close() else: reload(sys) sys.setdefaultencoding('utf-8') unicode(result) self.textedit.setText(result)