Cannot close a dialog PyQt5

I have the following 2 classes. From UI_mainwindow I open a dialog as seen below. I want that dialog to close when I click on one of those 2 buttons (createProject_btn, openProject_btn). Though nothing seems to be working.

I know this kind of questions have been asked million times, and I’m sure there are duplicates, but my eyes are so new to the python, I cannot follow the patterns. Hence, any help is appreciated.

Note: the ui files are pretty simple, one button on UI_mainwindow to open the dialog, 2 buttons on the dialog to set a property inside and close the dialog.

Ui_mainWindow

import os

from .createOrOpenProjectDialog import CreateOrOpenProjectDialog
from qgis.PyQt import uic
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import (QDialog)

FORM_CLASS, _ = uic.loadUiType(os.path.join(os.path.dirname(__file__), 'ui', 'window.ui'))

class Ui_mainWindow(QtWidgets.QDialog, FORM_CLASS):
    def __init__(self, parent=None):
        """Constructor."""
        super(Ui_mainWindow, self).__init__(parent)
        # Set up the user interface from Designer through FORM_CLASS.
        self.setupUi(self)
        self.connectSignalsSlots()

    def connectSignalsSlots(self):
        print("main.connectSignalsSlots 1")
        self.pushButton1.clicked.connect(self.createProject)
        print("main.connectSignalsSlots 2")
        
    def createProject(self):
        dialog = MyDialog(self)
        print(dialog.exec())
        dialog.showOutput()

class MyDialog(QDialog):
    def __init__(self, parent=None):
        super().__init__(parent)
        # .dialog is just a handle - class property that we created here
        self.dialog = CreateOrOpenProjectDialog(self)
    
    def showOutput(self):
        print("showOutput:")
        print(self.dialog.clickedButton)

CreateOrOpenProjectDialog

import os

from qgis.PyQt import uic
from PyQt5.QtWidgets import (QDialog)

# This loads your .ui file so that PyQt can populate your plugin with the elements from Qt Designer
FORM_CLASS, _ = uic.loadUiType(os.path.join(os.path.dirname(__file__), 'ui', 'dialog.ui'))

class CreateOrOpenProjectDialog(QDialog, FORM_CLASS):
    def __init__(self, parent=None):
        """Constructor."""
        super(CreateOrOpenProjectDialog, self).__init__(parent)
        self.setupUi(parent)
        self.connectSignalsSlots()

    def connectSignalsSlots(self):
        # todo: figure out if actions are better to use then direct events
        # self.action_create_project.triggered.connect(self.createProject)
        self.createProject_btn.clicked.connect(self.createProject)
        self.openProject_btn.clicked.connect(self.openProject)

    def createProject(self):
        print("dialog.createProject")
        self.clickedButton = "createProj"
        self.accept()
        
    def openProject(self):
        print("dialog.openProject")
        self.clickedButton = "openProj"
        self.accept()

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật