Skip to content

Instantly share code, notes, and snippets.

@claudiug
Created March 23, 2020 14:26
Show Gist options
  • Save claudiug/5ff1da6eb7ed1b13bc2c9905ef7b7d50 to your computer and use it in GitHub Desktop.
Save claudiug/5ff1da6eb7ed1b13bc2c9905ef7b7d50 to your computer and use it in GitHub Desktop.
class CustomDialog(QDialog):
def __init__(self, *args, **kwargs):
super(CustomDialog, self).__init__(*args, **kwargs)
self.setWindowTitle("HELLO!")
QBtn = QDialogButtonBox.Ok | QDialogButtonBox.Cancel
self.buttonBox = QDialogButtonBox(QBtn)
self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject)
self.layout = QVBoxLayout()
self.layout.addWidget(self.buttonBox)
self.setLayout(self.layout)
class MainWindow(QMainWindow):
# def __init__ etc.
# ... not shown for clarity
def onMyToolBarButtonClick(self, s):
print("click", s)
dlg = CustomDialog(self)
if dlg.exec_(): # THIs will kill the app
print("Success!")
else:
print("Cancel!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment