from week14 import *
import serial
from urllib.request import urlopen


class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
    def __init__(self, *args, **kwargs):
        QtWidgets.QMainWindow.__init__(self, *args, **kwargs)
        self.setupUi(self)
        self.Serial_port = serial.Serial ('COM13', 9600)
        
        # A partir de aqui ya va lo tuyo (tu logica)
        self.mover.clicked.connect(self.move)
        self.detener.clicked.connect(self.stop)
        self.zeros.clicked.connect(self.origin)

    def move(self):
        print("Moving")
        if self.Serial_port:
           self.Serial_port.write(b'0')
    def stop(self):
        print("Stop")
        if self.Serial_port:
           self.Serial_port.write(b'1')
    def origin(self):
        print("Return to zero")
        if self.Serial_port:
           self.Serial_port.write(b'2')

if __name__ == '__main__':
    app = QtWidgets.QApplication([])
    window = MainWindow()
    window.show()
    app.exec()