from PyQt5.QtWidgets import QDialog class HotkeyBrushesDialog(QDialog): def __init__(self, uihotkeybrushes, parent=None): super(HotkeyBrushesDialog, self).__init__(parent) self.uihotkeybrushes = uihotkeybrushes def accept(self): self.uihotkeybrushes.hotkeybrushes.writeSettings() super(HotkeyBrushesDialog, self).accept() def closeEvent(self, event): event.accept()