Hola estimados necesito realizar una conversión, pasar metros x segundo a kilometros por hora lo cual es m/s * 3.6 = km/h cree una aplicacion grafica en la cual tengo 3 botones 1- convertir 2- limpiar 3- salir, los botones limpiar y salir ya los tengo con su respectiva funcion solo me falta como realizar la conversion de metros x segundo a kilometros por hora cuando le de click al boton convertir.
Les dejo el codigo.
iniciar.py
import sys from PyQt5 import QtWidgets, uic, QtCore # Cargar archivo .ui form_class = uic.loadUiType("conversor.ui")[0] class MyForm(QtWidgets.QMainWindow, form_class): def __init__(self, parent=None): QtWidgets.QMainWindow.__init__(self, parent) self.setupUi(self) self.btn_clean.clicked.connect(self.clear) self.btn_exit.clicked.connect(self.close) def clear(self): self.valor_1.clear() self.valor_2.clear() def exit(self): self.btn_exit.exit() app = QtWidgets.QApplication(sys.argv) window = MyForm(None) window.show() app.exec_()
conversor.ui
<?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>MainWindow</class> <widget class="QMainWindow" name="MainWindow"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>732</width> <height>600</height> </rect> </property> <property name="windowTitle"> <string>conversor</string> </property> <widget class="QWidget" name="centralwidget"> <widget class="QPushButton" name="btn_calc"> <property name="geometry"> <rect> <x>20</x> <y>310</y> <width>191</width> <height>71</height> </rect> </property> <property name="text"> <string>Convertir</string> </property> </widget> <widget class="QTextEdit" name="valor_1"> <property name="geometry"> <rect> <x>190</x> <y>96</y> <width>171</width> <height>51</height> </rect> </property> </widget> <widget class="QTextEdit" name="valor_2"> <property name="geometry"> <rect> <x>190</x> <y>160</y> <width>171</width> <height>61</height> </rect> </property> </widget> <widget class="QPushButton" name="btn_clean"> <property name="geometry"> <rect> <x>270</x> <y>310</y> <width>191</width> <height>71</height> </rect> </property> <property name="text"> <string>Limpiar</string> </property> </widget> <widget class="QPushButton" name="btn_exit"> <property name="geometry"> <rect> <x>500</x> <y>310</y> <width>191</width> <height>71</height> </rect> </property> <property name="text"> <string>Salir</string> </property> </widget> <widget class="QLabel" name="label"> <property name="geometry"> <rect> <x>80</x> <y>110</y> <width>55</width> <height>31</height> </rect> </property> <property name="styleSheet"> <string notr="true">font: 75 10pt "MS Shell Dlg 2";</string> </property> <property name="text"> <string><html><head/><body><p align="center">M/s</p></body></html></string> </property> </widget> <widget class="QLabel" name="label_1"> <property name="geometry"> <rect> <x>80</x> <y>180</y> <width>55</width> <height>31</height> </rect> </property> <property name="styleSheet"> <string notr="true">font: 75 10pt "MS Shell Dlg 2";</string> </property> <property name="text"> <string><html><head/><body><p align="center">KM/H</p></body></html></string> </property> </widget> </widget> <widget class="QStatusBar" name="statusbar"/> </widget> <resources/> <connections/> </ui>