Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Python by pasaranax ( 17 years ago )
#!/usr/bin/python2.5
# -*- coding: utf-8 -*-

import sys
import os
import commands
from tempfile import mkstemp
from PyQt4.QtGui import *
from PyQt4.QtCore import *

class QEnca(QMainWindow):
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        self.setWindowTitle(u"QEnca")
        self.resize(600,600)
        central = QWidget()
        self.setCentralWidget(central)
        
        self.text = QPlainTextEdit(central)
        self.button = QPushButton(central)
        self.button.setText(u"Decode this")
        
        layout = QVBoxLayout(central)
        layout.addWidget(self.text)
        layout.addWidget(self.button)
        self.connect(self.button, SIGNAL("clicked()"), self.decode)
        
        self.statusBar().showMessage(u"Я куенка :)")
        
    def decode(self):
        (fd, filename) = mkstemp()
        tmpfile = open(filename, "w")
        tmpfile.write(self.text.toPlainText())
        tmpfile.close()
        
        self.statusBar().showMessage(commands.getoutput("enca " + filename + " | tail -1"))
        
        out = commands.getoutput("enconv -с " + filename)
        self.text.setPlainText(unicode(open(filename).read()))
        
        #os.remove(filename)
        
if __name__ == '__main__':
    app = QApplication(sys.argv)
    window = QEnca()
    window.show()
    sys.exit(app.exec_())

 

Revise this Paste

Your Name: Code Language: