|
| 1 | +# @autor: Magno Efren |
| 2 | +# Youtube: https://www.youtube.com/c/MagnoEfren |
| 3 | + |
| 4 | +import sys |
| 5 | +from menu import * |
| 6 | +from PyQt5 import QtCore |
| 7 | +from PyQt5.QtCore import QPropertyAnimation |
| 8 | +from PyQt5 import QtCore, QtGui, QtWidgets |
| 9 | + |
| 10 | +class MiApp(QtWidgets.QMainWindow): |
| 11 | + def __init__(self): |
| 12 | + super().__init__() |
| 13 | + self.ui = Ui_MainWindow() |
| 14 | + self.ui.setupUi(self) |
| 15 | + |
| 16 | + #eliminar barra y de titulo - opacidad |
| 17 | + self.setWindowFlag(QtCore.Qt.FramelessWindowHint) |
| 18 | + self.setWindowOpacity(1) |
| 19 | + |
| 20 | + #SizeGrip |
| 21 | + self.gripSize = 10 |
| 22 | + self.grip = QtWidgets.QSizeGrip(self) |
| 23 | + self.grip.resize(self.gripSize, self.gripSize) |
| 24 | + |
| 25 | + # mover ventana |
| 26 | + self.ui.frame_superior.mouseMoveEvent = self.mover_ventana |
| 27 | + |
| 28 | + #acceder a las paginas |
| 29 | + self.ui.bt_inicio.clicked.connect(lambda: self.ui.stackedWidget.setCurrentWidget(self.ui.page)) |
| 30 | + self.ui.bt_uno.clicked.connect(lambda: self.ui.stackedWidget.setCurrentWidget(self.ui.page_uno)) |
| 31 | + self.ui.bt_dos.clicked.connect(lambda: self.ui.stackedWidget.setCurrentWidget(self.ui.page_dos)) |
| 32 | + self.ui.bt_tres.clicked.connect(lambda: self.ui.stackedWidget.setCurrentWidget(self.ui.page_tres)) |
| 33 | + self.ui.bt_cuatro.clicked.connect(lambda: self.ui.stackedWidget.setCurrentWidget(self.ui.page_cuatro)) |
| 34 | + self.ui.bt_cinco.clicked.connect(lambda: self.ui.stackedWidget.setCurrentWidget(self.ui.page_cinco)) |
| 35 | + |
| 36 | + #control barra de titulos |
| 37 | + self.ui.bt_minimizar.clicked.connect(self.control_bt_minimizar) |
| 38 | + self.ui.bt_restaurar.clicked.connect(self.control_bt_normal) |
| 39 | + self.ui.bt_maximizar.clicked.connect(self.control_bt_maximizar) |
| 40 | + self.ui.bt_cerrar.clicked.connect(lambda: self.close()) |
| 41 | + |
| 42 | + self.ui.bt_restaurar.hide() |
| 43 | + |
| 44 | + #menu lateral |
| 45 | + self.ui.bt_menu.clicked.connect(self.mover_menu) |
| 46 | + |
| 47 | + def control_bt_minimizar(self): |
| 48 | + self.showMinimized() |
| 49 | + |
| 50 | + def control_bt_normal(self): |
| 51 | + self.showNormal() |
| 52 | + self.ui.bt_restaurar.hide() |
| 53 | + self.ui.bt_maximizar.show() |
| 54 | + |
| 55 | + def control_bt_maximizar(self): |
| 56 | + self.showMaximized() |
| 57 | + self.ui.bt_maximizar.hide() |
| 58 | + self.ui.bt_restaurar.show() |
| 59 | + |
| 60 | + def mover_menu(self): |
| 61 | + if True: |
| 62 | + width = self.ui.frame_lateral.width() |
| 63 | + normal = 0 |
| 64 | + if width==0: |
| 65 | + extender = 200 |
| 66 | + else: |
| 67 | + extender = normal |
| 68 | + self.animacion = QPropertyAnimation(self.ui.frame_lateral, b'minimumWidth') |
| 69 | + self.animacion.setDuration(300) |
| 70 | + self.animacion.setStartValue(width) |
| 71 | + self.animacion.setEndValue(extender) |
| 72 | + self.animacion.setEasingCurve(QtCore.QEasingCurve.InOutQuart) |
| 73 | + self.animacion.start() |
| 74 | + |
| 75 | + ## SizeGrip |
| 76 | + def resizeEvent(self, event): |
| 77 | + rect = self.rect() |
| 78 | + self.grip.move(rect.right() - self.gripSize, rect.bottom() - self.gripSize) |
| 79 | + |
| 80 | + ## mover ventana |
| 81 | + def mousePressEvent(self, event): |
| 82 | + self.clickPosition = event.globalPos() |
| 83 | + |
| 84 | + def mover_ventana(self, event): |
| 85 | + if self.isMaximized() == False: |
| 86 | + if event.buttons() == QtCore.Qt.LeftButton: |
| 87 | + self.move(self.pos() + event.globalPos() - self.clickPosition) |
| 88 | + self.clickPosition = event.globalPos() |
| 89 | + event.accept() |
| 90 | + |
| 91 | + if event.globalPos().y() <=20: |
| 92 | + self.showMaximized() |
| 93 | + else: |
| 94 | + self.showNormal() |
| 95 | + |
| 96 | + |
| 97 | +if __name__ == "__main__": |
| 98 | + app = QtWidgets.QApplication(sys.argv) |
| 99 | + mi_app = MiApp() |
| 100 | + mi_app.show() |
| 101 | + sys.exit(app.exec_()) |
| 102 | + |
| 103 | + |
0 commit comments