# _*_ coding: utf-8 -*-
from PyQt4.QtGui import *
from PyQt4.QtCore import *
import sys
class mainWindow(QWidget):
def __init__(self, parent = None):
QWidget.__init__(self, parent)
self.setWindowTitle(u'Koнвертер')
input = QLineEdit(self)
input.setGeometry(300, 20, 250, 70)
output = QLineEdit(self)
output.setGeometry(300, 110, 250, 70)
eb = QPushButton(u'Закрыть' , self)
eb.setGeometry(650, 300, 130, 70)
cb = QPushButton(u'Конвертировать' , self)
cb.setGeometry(300, 190, 250, 70)
inp = QLabel(u'Ввод', self)
outp = QLabel(u'Вывод', self)
inp.setGeometry(200, 20, 100, 70)
outp.setGeometry(200, 110, 100, 70)
self.connect( inp, SIGNAL('inp.textChanged(QString)'),mainWindow.slot1)
def slot1(self, QString):
print QString
app = QApplication(sys.argv)
mv = mainWindow()
mv.show()
sys.exit(app.exec_())
#!/usr/bin/env python
# coding: utf-8
import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *
class MainWindow(QMainWindow):
inpEdit = None
inpLbl = None
outEdit = None
outLbl = None
quitBtn = None
convBtn = None
def __init__(self,parent=None):
super(MainWindow,self).__init__(parent)
self.setWindowTitle(u'Koнвертер')
self.resize(800,370)
self.inpEdit = QLineEdit(self)
self.inpEdit.setGeometry(300, 20, 250, 70)
QObject.connect(self.inpEdit,SIGNAL('textChanged(QString)'),self.onInpLblTextChanged)
self.outEdit = QLineEdit(self)
self.outEdit.setGeometry(300, 110, 250, 70)
self.inpLbl = QLabel(u'Ввод', self)
self.inpLbl.setGeometry(200, 20, 100, 70)
self.outLbl = QLabel(u'Вывод', self)
self.outLbl.setGeometry(200, 110, 100, 70)
self.quitBtn = QPushButton(u'Закрыть', self)
self.quitBtn.setGeometry(650, 300, 130, 70)
QObject.connect(self.quitBtn,SIGNAL('clicked()'),self.onQuitBtnClicked)
self.convBtn = QPushButton(u'Конвертировать', self)
self.convBtn.setGeometry(300, 190, 250, 70)
@pyqtSlot()
def onQuitBtnClicked(self):
self.close()
@pyqtSlot(QString)
def onInpLblTextChanged(self, string):
print string
if __name__ == '__main__':
app = QApplication(sys.argv)
mw = MainWindow()
mw.show()
sys.exit(app.exec_())
self.connect( inp, SIGNAL('inp.textChanged(QString)'),mainWindow.slot1)
self.connect(inp, SIGNAL('textChanged(QString)'), self.slot1)
self.connect(input, SIGNAL('textChanged(QString)'), self.slot1)