Advertisement
Rafsys

convertidor

Jun 2nd, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. import sys
  2. from PyQt5 import QtCore, QtGui, uic
  3. from PyQt5 import QtWidgets
  4. form_class = uic.loadUiType("tempconv.ui")[0]
  5.  
  6. class MyWindowClass(QtWidgets.QMainWindow, form_class):
  7. def __init__(self, parent=None):
  8. QtWidgets.QMainWindow.__init__(self, parent)
  9. self.setupUi(self)
  10. self.btn_CtoF.clicked.connect(self.btn_CtoF_clicked)
  11. self.btn_FtoC.clicked.connect(self.btn_FtoC_clicked)
  12.  
  13.  
  14.  
  15. def btn_CtoF_clicked(self):
  16. cel = float(self.editCel.text())
  17. fahr = cel * 9 / 5.0 + 32
  18. self.spinFahr.setValue(int(fahr + 0.5))
  19.  
  20.  
  21. def btn_FtoC_clicked(self):
  22. fahr = self.spinFahr.value()
  23. cel = ((fahr - 32) * 5) / 9
  24. self.editCel.setText(str(cel))
  25.  
  26. app = QtWidgets.QApplication(sys.argv)
  27. MyWindow = MyWindowClass(None)
  28. MyWindow.show()
  29. app.exec_()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement