Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 25th, 2012  |  syntax: Python  |  size: 0.70 KB  |  hits: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #  -*- coding: utf-8 -*-
  2.  
  3.  
  4. from PyQt4 import QtCore, QtGui
  5. import ui_Calc
  6.  
  7.  
  8. def calc():
  9.  
  10.     try:
  11.         res = self.first - self.second
  12.     except:
  13.         res = "?"
  14.     MainWindow.result.setText(QString (res));
  15.  
  16.        
  17. class MyWindow(QtGui.QWidget, ui_Calc.Ui_MainWindow):
  18.    
  19.  
  20.     def __init__(self , parent = None):
  21.         QtGui.QWidget.__init__(self, parent)
  22.         self.setupUi(self)
  23.         self.connect(self.exit, QtCore.SIGNAL("clicked()"), self.close)
  24.         self.connect(self.calculate,QtCore.SIGNAL("clicked()"),calc)
  25.  
  26. if __name__ == "__main__":
  27.     import sys
  28.     app = QtGui.QApplication(sys.argv)
  29.     window = MyWindow()
  30.     window.show()
  31.     sys.exit(app.exec_())