#!/usr/bin/env python # # The PYTHagoras application # import sys from qt import * import math class Pytagoras(QWidget): def __init__(self, *args): QWidget.__init__(self, *args) self.setCaption("PYTHagoras - 0.1") self.setGeometry(0,0,230,130) self.kateteEtText = QLabel("Katete1:", self) self.kateteEtText.setGeometry(10,10,100,25) self.kateteToText = QLabel("Katete2:", self) self.kateteToText.setGeometry(10,50,100,25) self.kateteEt = QLineEdit("Skriv her...", self) self.kateteEt.setGeometry(90,10,100,25) self.kateteTo = QLineEdit("Skriv her...", self) self.kateteTo.setGeometry(90,50,100,25) self.cmEtText = QLabel("cm", self) self.cmEtText.setGeometry(195,10,100,25) self.cmToText = QLabel("cm", self) self.cmToText.setGeometry(195,50,100,25) self.calculate = QPushButton("Calculate!", self) self.calculate.setGeometry(60,90,100,25) #Actions self.connect(self.calculate, SIGNAL("clicked()"), self.doCalculate) # Variables a = lineEdit.kateteEt() b = lineEdit.kateteTo() def doCalculate(self): c2 = a + b print "c2: ", c2 if __name__ == "__main__": app = QApplication(sys.argv) app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT('quit()')) pytagoras = Pytagoras() pytagoras.show() app.setMainWidget(pytagoras) app.exec_loop()