Return to Snippet

Revision: 16620
at August 10, 2009 04:42 by s1nerg1a


Initial Code
# -*- coding: utf-8 -*-

import sys
from PyQt4.QtCore import SIGNAL
from PyQt4.QtGui import *
from calc_ui import Ui_calc

class Calc(QWidget, Ui_calc):

	def __init__(self, parent = None):
		QWidget.__init__(self, parent)
		self.setupUi(self)
		self.connect(self.sum, SIGNAL("clicked()"),self.sumar)
		self.connect(self.res, SIGNAL("clicked()"),self.restar)
		self.connect(self.mul, SIGNAL("clicked()"),self.multiplicar)
		self.connect(self.div, SIGNAL("clicked()"),self.dividir)
		
	def sumar(self):
		self.result.setText( str( float(self.num1.text()) + float(self.num2.text()) ) )

	def restar(self):
		self.result.setText( str( float(self.num1.text()) - float(self.num2.text()) ) )
		
	def multiplicar(self):
		self.result.setText( str( float(self.num1.text()) * float(self.num2.text()) ) )
		
	def dividir(self):
		self.result.setText( str( float(self.num1.text()) / float(self.num2.text()) ) )

if __name__ == "__main__":
	app = QApplication(sys.argv)
	window = Calc()
	window.show()
	sys.exit(app.exec_())

Initial URL

                                

Initial Description

                                

Initial Title
Ejemplo de PyQt

Initial Tags

                                

Initial Language
Python