Last active
September 7, 2018 16:05
-
-
Save hcosta/0bc19080efba6ebcb3990e3963578efe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PyQt5.QtWidgets import QApplication, QMainWindow | |
class MainWindow(QMainWindow): | |
def __init__(self, *args, **kwargs): | |
super(MainWindow, self).__init__(*args, **kwargs) | |
self.setWindowTitle("Hola mundo") | |
self.setFixedSize(400, 200) | |
if __name__ == "__main__": | |
app = QApplication([]) | |
window = MainWindow() | |
window.show() | |
app.exec_() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PyQt5.QtWidgets import QApplication, QDialog | |
class Dialog(QDialog): | |
def __init__(self, *args, **kwargs): | |
super(Dialog, self).__init__(*args, **kwargs) | |
self.setWindowTitle("Hola mundo") | |
self.setFixedSize(400, 200) | |
if __name__ == "__main__": | |
app = QApplication([]) | |
dialog = Dialog() | |
dialog.show() | |
app.exec_() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PyQt5.QtWidgets import QApplication, QMainWindow, QDialog, QPushButton | |
class MainWindow(QMainWindow): | |
def __init__(self, *args, **kwargs): | |
super(MainWindow, self).__init__(*args, **kwargs) | |
self.setWindowTitle("Hola mundo") | |
self.setFixedSize(400, 200) | |
self.button = QPushButton(self, text="Mostrar diálogo") | |
self.button.clicked.connect(self.show_dialog) | |
def show_dialog(self): | |
dialog = Dialog(self) # self hace referencia al padre | |
dialog.show() | |
class Dialog(QDialog): | |
def __init__(self, *args, **kwargs): | |
super(Dialog, self).__init__(*args, **kwargs) | |
self.setWindowTitle("Soy un popup") | |
self.setFixedSize(200, 100) | |
if __name__ == "__main__": | |
app = QApplication([]) | |
dialog = MainWindow() | |
dialog.show() | |
app.exec_() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment