Используя PyQt6 при создании виджета, как я могу связать высоту и ширину окна? ⇐ Python
-
Anonymous
Используя PyQt6 при создании виджета, как я могу связать высоту и ширину окна?
I am trying to make a window using pyqt6 in python 3.10 where if you modify the height or width, the other is automatically modified as well, maintaining a constant relationship.
In addition, this movement is fluid, that is, while I am dragging with the mouse to a new measurement, the other one is also being modified.
How could it be done, thanks in advance
import sys from PyQt6.QtWidgets import QApplication, QWidget class Ventana(QWidget): def __init__(self): super().__init__() self.setWindowTitle("Ventana de PyQt6") self.setGeometry(100, 100, 400, 200) def resizeEvent(self, event): # Obtener las nuevas dimensiones nueva_anchura = event.size().width() nueva_altura = event.size().height() # Imprimir las nuevas dimensiones print(f"Ancho: {nueva_anchura}, Altura: {nueva_altura}") if __name__ == "__main__": app = QApplication(sys.argv) ventana = Ventana() ventana.show() sys.exit(app.exec())
Источник: https://stackoverflow.com/questions/780 ... -and-width
I am trying to make a window using pyqt6 in python 3.10 where if you modify the height or width, the other is automatically modified as well, maintaining a constant relationship.
In addition, this movement is fluid, that is, while I am dragging with the mouse to a new measurement, the other one is also being modified.
How could it be done, thanks in advance
import sys from PyQt6.QtWidgets import QApplication, QWidget class Ventana(QWidget): def __init__(self): super().__init__() self.setWindowTitle("Ventana de PyQt6") self.setGeometry(100, 100, 400, 200) def resizeEvent(self, event): # Obtener las nuevas dimensiones nueva_anchura = event.size().width() nueva_altura = event.size().height() # Imprimir las nuevas dimensiones print(f"Ancho: {nueva_anchura}, Altura: {nueva_altura}") if __name__ == "__main__": app = QApplication(sys.argv) ventana = Ventana() ventana.show() sys.exit(app.exec())
Источник: https://stackoverflow.com/questions/780 ... -and-width