def __init__(self): self.clipboard = QtGui.QApplication.clipboard() self.mainwindow = MainWindow() self.mainwindow.show() self.widget = LinWidget() self.clipboard.selectionChanged.connect(self.display_widget) QtCore.QTextCodec.setCodecForTr(QtCore.QTextCodec.codecForName("utf8"))
class Lindict(): def __init__(self): self.clipboard = QtGui.QApplication.clipboard() self.mainwindow = MainWindow() self.mainwindow.show() self.widget = LinWidget() self.clipboard.selectionChanged.connect(self.display_widget) QtCore.QTextCodec.setCodecForTr(QtCore.QTextCodec.codecForName("utf8")) def display_widget(self): if self.mainwindow.real_time_status: test = self.clipboard.text("plain", QtGui.QClipboard.Selection) test = str(test).strip() if test != str(self.mainwindow.lineEdit.text()): self.widget.Translate() self.cursor = QtGui.QCursor.pos() self.widget.setGeometry(self.cursor.x(), self.cursor.y(), 300, 200) self.widget.show()