Source

Kiva Editor's Assistant / gkea.py

Full commit
import sys
import StringIO
import kea
from clipboard import *

#
# Import the Qt based user interface
#

from PyQt4 import QtCore,QtGui
from build.kivaui import Ui_MainWindow

# Create a class for our main window
class Main(QtGui.QMainWindow):
    def __init__(self):
        QtGui.QMainWindow.__init__(self)
        # This is always the same
        self.ui=Ui_MainWindow()
        self.ui.setupUi(self)
        # process whatever's on the clipboard
        self._process_clipboard()

    def _process_clipboard(self):
        # copy whatever's on the clipboard into the original description text edit
        original_descr = get_clipboard_text()
        self.ui.original_loan_descr.setPlainText(original_descr)

        # process that string
        edit_assistant = kea.EditAssistant(StringIO.StringIO(original_descr))

        # put the processed string into the edited text control
        self.ui.modified_loan_descr.setPlainText(edit_assistant.edited_text)



def main():
    app = QtGui.QApplication(sys.argv)
    window=Main()
    window.show()
    sys.exit(app.exec_())

if __name__ == '__main__':
    main()