Better way to convert dialog from QT Creator and incorporate it into my mainwindow
<p>I'm creating a simple popup box that contains settings. I want this to be a modal dialog box. I created the window from qt creator and converted the .ui to .py using pyuic. With the main window i'm able to import the .py file into my main project so that I can make changes to the gui and not have them overwritten every time that I update the GUI within QT Creator. When I try the same approach with my dialog box I was able to do so but then had no way of making the window modal. My fix was to bring the code from the file into the main py script. This has the disadvantage of me not being able to update the window from QT Creator now. Is there a better way to incorporate the new popup window that i created from QT Designer into my main GUI? When you click popup that is the window I wish to incorporate.</p>

<p>All the files:
main.py</p>

<pre><code>from PyQt4 import QtCore, QtGui

try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    def _fromUtf8(s):
        return s

try:
    _encoding = QtGui.QApplication.UnicodeUTF8
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig)

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        MainWindow.resize(637, 559)
        self.centralWidget = QtGui.QWidget(MainWindow)
        self.centralWidget.setObjectName(_fromUtf8("centralWidget"))
        self.horizontalLayout = QtGui.QHBoxLayout(self.centralWidget)
        self.horizontalLayout.setMargin(2)
        self.horizontalLayout.setSpacing(1)
        self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
        spacerItem = QtGui.QSpacerItem(13, 485, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
        self.horizontalLayout.addItem(spacerItem)
        self.popup = QtGui.QPushButton(self.centralWidget)
        self.popup.setObjectName(_fromUtf8("popup"))
        self.horizontalLayout.addWidget(self.popup)
        self.verticalLayout = QtGui.QVBoxLayout()
        self.verticalLayout.setMargin(2)
        self.verticalLayout.setSpacing(1)
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.textBrowser = QtGui.QTextBrowser(self.centralWidget)
        self.textBrowser.setObjectName(_fromUtf8("textBrowser"))
        self.verticalLayout.addWidget(self.textBrowser)
        self.horizontalLayout_7 = QtGui.QHBoxLayout()
        self.horizontalLayout_7.setMargin(2)
        self.horizontalLayout_7.setSpacing(1)
        self.horizontalLayout_7.setObjectName(_fromUtf8("horizontalLayout_7"))
        self.open_port = QtGui.QPushButton(self.centralWidget)
        self.open_port.setObjectName(_fromUtf8("open_port"))
        self.horizontalLayout_7.addWidget(self.open_port)
        self.closeButton = QtGui.QPushButton(self.centralWidget)
        self.closeButton.setObjectName(_fromUtf8("closeButton"))
        self.horizontalLayout_7.addWidget(self.closeButton)
        self.verticalLayout.addLayout(self.horizontalLayout_7)
        self.horizontalLayout.addLayout(self.verticalLayout)
        spacerItem1 = QtGui.QSpacerItem(13, 485, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
        self.horizontalLayout.addItem(spacerItem1)
        MainWindow.setCentralWidget(self.centralWidget)
        self.statusBar = QtGui.QStatusBar(MainWindow)
        self.statusBar.setObjectName(_fromUtf8("statusBar"))
        MainWindow.setStatusBar(self.statusBar)
        self.actionSettings = QtGui.QAction(MainWindow)
        self.actionSettings.setObjectName(_fromUtf8("actionSettings"))

        self.retranslateUi(MainWindow)
        QtCore.QObject.connect(self.closeButton, QtCore.SIGNAL(_fromUtf8("clicked()")), MainWindow.close)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))
        self.popup.setText(_translate("MainWindow", "popup", None))
        self.open_port.setText(_translate("MainWindow", "Open Port", None))
        self.closeButton.setText(_translate("MainWindow", "Close", None))
        self.actionSettings.setText(_translate("MainWindow", "Settings", None))
</code></pre>

<p>comsettings.py what i'm hoping to turn into a dialog box</p>

<pre><code>from PyQt4 import QtCore, QtGui

try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    def _fromUtf8(s):
        return s

try:
    _encoding = QtGui.QApplication.UnicodeUTF8
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig)

class Ui_comSettings(object):
    def setupUi(self, comSettings):
        comSettings.setObjectName(_fromUtf8("comSettings"))
        comSettings.resize(252, 209)
        self.verticalLayout = QtGui.QVBoxLayout(comSettings)
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.horizontalLayout_13 = QtGui.QHBoxLayout()
        self.horizontalLayout_13.setObjectName(_fromUtf8("horizontalLayout_13"))
        self.label_13 = QtGui.QLabel(comSettings)
        self.label_13.setMinimumSize(QtCore.QSize(70, 0))
        self.label_13.setObjectName(_fromUtf8("label_13"))
        self.horizontalLayout_13.addWidget(self.label_13)
        self.portBox_3 = QtGui.QComboBox(comSettings)
        self.portBox_3.setMinimumSize(QtCore.QSize(150, 0))
        self.portBox_3.setObjectName(_fromUtf8("portBox_3"))
        self.horizontalLayout_13.addWidget(self.portBox_3)
        spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.horizontalLayout_13.addItem(spacerItem)
        self.verticalLayout.addLayout(self.horizontalLayout_13)
        self.horizontalLayout_14 = QtGui.QHBoxLayout()
        self.horizontalLayout_14.setObjectName(_fromUtf8("horizontalLayout_14"))
        self.label_14 = QtGui.QLabel(comSettings)
        self.label_14.setMinimumSize(QtCore.QSize(70, 0))
        self.label_14.setObjectName(_fromUtf8("label_14"))
        self.horizontalLayout_14.addWidget(self.label_14)
        self.baudBox_3 = QtGui.QComboBox(comSettings)
        self.baudBox_3.setMinimumSize(QtCore.QSize(150, 0))
        self.baudBox_3.setObjectName(_fromUtf8("baudBox_3"))
        self.baudBox_3.addItem(_fromUtf8(""))
        self.baudBox_3.addItem(_fromUtf8(""))
        self.baudBox_3.addItem(_fromUtf8(""))
        self.baudBox_3.addItem(_fromUtf8(""))
        self.baudBox_3.addItem(_fromUtf8(""))
        self.baudBox_3.addItem(_fromUtf8(""))
        self.baudBox_3.addItem(_fromUtf8(""))
        self.baudBox_3.addItem(_fromUtf8(""))
        self.baudBox_3.addItem(_fromUtf8(""))
        self.baudBox_3.addItem(_fromUtf8(""))
        self.baudBox_3.addItem(_fromUtf8(""))
        self.baudBox_3.addItem(_fromUtf8(""))
        self.baudBox_3.addItem(_fromUtf8(""))
        self.baudBox_3.addItem(_fromUtf8(""))
        self.baudBox_3.addItem(_fromUtf8(""))
        self.horizontalLayout_14.addWidget(self.baudBox_3)
        spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.horizontalLayout_14.addItem(spacerItem1)
        self.verticalLayout.addLayout(self.horizontalLayout_14)
        self.horizontalLayout_15 = QtGui.QHBoxLayout()
        self.horizontalLayout_15.setObjectName(_fromUtf8("horizontalLayout_15"))
        self.label_15 = QtGui.QLabel(comSettings)
        self.label_15.setMinimumSize(QtCore.QSize(70, 0))
        self.label_15.setObjectName(_fromUtf8("label_15"))
        self.horizontalLayout_15.addWidget(self.label_15)
        self.dataBox_3 = QtGui.QComboBox(comSettings)
        self.dataBox_3.setMinimumSize(QtCore.QSize(150, 0))
        self.dataBox_3.setObjectName(_fromUtf8("dataBox_3"))
        self.dataBox_3.addItem(_fromUtf8(""))
        self.dataBox_3.addItem(_fromUtf8(""))
        self.horizontalLayout_15.addWidget(self.dataBox_3)
        spacerItem2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.horizontalLayout_15.addItem(spacerItem2)
        self.verticalLayout.addLayout(self.horizontalLayout_15)
        self.horizontalLayout_16 = QtGui.QHBoxLayout()
        self.horizontalLayout_16.setObjectName(_fromUtf8("horizontalLayout_16"))
        self.label_16 = QtGui.QLabel(comSettings)
        self.label_16.setMinimumSize(QtCore.QSize(70, 0))
        self.label_16.setObjectName(_fromUtf8("label_16"))
        self.horizontalLayout_16.addWidget(self.label_16)
        self.parityBox_3 = QtGui.QComboBox(comSettings)
        self.parityBox_3.setMinimumSize(QtCore.QSize(150, 0))
        self.parityBox_3.setObjectName(_fromUtf8("parityBox_3"))
        self.parityBox_3.addItem(_fromUtf8(""))
        self.parityBox_3.addItem(_fromUtf8(""))
        self.parityBox_3.addItem(_fromUtf8(""))
        self.parityBox_3.addItem(_fromUtf8(""))
        self.parityBox_3.addItem(_fromUtf8(""))
        self.horizontalLayout_16.addWidget(self.parityBox_3)
        spacerItem3 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.horizontalLayout_16.addItem(spacerItem3)
        self.verticalLayout.addLayout(self.horizontalLayout_16)
        self.horizontalLayout_17 = QtGui.QHBoxLayout()
        self.horizontalLayout_17.setObjectName(_fromUtf8("horizontalLayout_17"))
        self.label_17 = QtGui.QLabel(comSettings)
        self.label_17.setMinimumSize(QtCore.QSize(70, 0))
        self.label_17.setObjectName(_fromUtf8("label_17"))
        self.horizontalLayout_17.addWidget(self.label_17)
        self.stopBox_3 = QtGui.QComboBox(comSettings)
        self.stopBox_3.setMinimumSize(QtCore.QSize(150, 0))
        self.stopBox_3.setObjectName(_fromUtf8("stopBox_3"))
        self.stopBox_3.addItem(_fromUtf8(""))
        self.stopBox_3.addItem(_fromUtf8(""))
        self.stopBox_3.addItem(_fromUtf8(""))
        self.horizontalLayout_17.addWidget(self.stopBox_3)
        spacerItem4 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.horizontalLayout_17.addItem(spacerItem4)
        self.verticalLayout.addLayout(self.horizontalLayout_17)
        self.horizontalLayout_18 = QtGui.QHBoxLayout()
        self.horizontalLayout_18.setObjectName(_fromUtf8("horizontalLayout_18"))
        self.label_18 = QtGui.QLabel(comSettings)
        self.label_18.setMinimumSize(QtCore.QSize(70, 0))
        self.label_18.setObjectName(_fromUtf8("label_18"))
        self.horizontalLayout_18.addWidget(self.label_18)
        self.fcBox_3 = QtGui.QComboBox(comSettings)
        self.fcBox_3.setMinimumSize(QtCore.QSize(150, 0))
        self.fcBox_3.setObjectName(_fromUtf8("fcBox_3"))
        self.fcBox_3.addItem(_fromUtf8(""))
        self.fcBox_3.addItem(_fromUtf8(""))
        self.fcBox_3.addItem(_fromUtf8(""))
        self.horizontalLayout_18.addWidget(self.fcBox_3)
        spacerItem5 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.horizontalLayout_18.addItem(spacerItem5)
        self.verticalLayout.addLayout(self.horizontalLayout_18)
        self.buttonBox = QtGui.QDialogButtonBox(comSettings)
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
        self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
        self.verticalLayout.addWidget(self.buttonBox)

        self.retranslateUi(comSettings)
        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), comSettings.accept)
        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), comSettings.reject)
        QtCore.QMetaObject.connectSlotsByName(comSettings)

    def retranslateUi(self, comSettings):
        comSettings.setWindowTitle(_translate("comSettings", "Dialog", None))
        self.label_13.setText(_translate("comSettings", "COM Port", None))
        self.label_14.setText(_translate("comSettings", "Baud Rate", None))
        self.baudBox_3.setItemText(0, _translate("comSettings", "110", None))
        self.baudBox_3.setItemText(1, _translate("comSettings", "300", None))
        self.baudBox_3.setItemText(2, _translate("comSettings", "600", None))
        self.baudBox_3.setItemText(3, _translate("comSettings", "1200", None))
        self.baudBox_3.setItemText(4, _translate("comSettings", "2400", None))
        self.baudBox_3.setItemText(5, _translate("comSettings", "4800", None))
        self.baudBox_3.setItemText(6, _translate("comSettings", "9600", None))
        self.baudBox_3.setItemText(7, _translate("comSettings", "14400", None))
        self.baudBox_3.setItemText(8, _translate("comSettings", "19200", None))
        self.baudBox_3.setItemText(9, _translate("comSettings", "38400", None))
        self.baudBox_3.setItemText(10, _translate("comSettings", "57600", None))
        self.baudBox_3.setItemText(11, _translate("comSettings", "115200", None))
        self.baudBox_3.setItemText(12, _translate("comSettings", "230400", None))
        self.baudBox_3.setItemText(13, _translate("comSettings", "460800", None))
        self.baudBox_3.setItemText(14, _translate("comSettings", "921600", None))
        self.label_15.setText(_translate("comSettings", "Data", None))
        self.dataBox_3.setItemText(0, _translate("comSettings", "8 bit", None))
        self.dataBox_3.setItemText(1, _translate("comSettings", "7 bit", None))
        self.label_16.setText(_translate("comSettings", "Parity", None))
        self.parityBox_3.setItemText(0, _translate("comSettings", "None", None))
        self.parityBox_3.setItemText(1, _translate("comSettings", "Odd", None))
        self.parityBox_3.setItemText(2, _translate("comSettings", "Even", None))
        self.parityBox_3.setItemText(3, _translate("comSettings", "Mark", None))
        self.parityBox_3.setItemText(4, _translate("comSettings", "Space", None))
        self.label_17.setText(_translate("comSettings", "Stop", None))
        self.stopBox_3.setItemText(0, _translate("comSettings", "1 bit", None))
        self.stopBox_3.setItemText(1, _translate("comSettings", "1.5 bit", None))
        self.stopBox_3.setItemText(2, _translate("comSettings", "2 bit", None))
        self.label_18.setText(_translate("comSettings", "Flow Control", None))
        self.fcBox_3.setItemText(0, _translate("comSettings", "None", None))
        self.fcBox_3.setItemText(1, _translate("comSettings", "Xon/Xoff", None))
        self.fcBox_3.setItemText(2, _translate("comSettings", "hardware", None))
</code></pre>

<p>Main file that incorporates everything together:</p>

<pre><code>from PyQt4 import QtCore, QtGui
from main import Ui_MainWindow
#from comsettings import Ui_comSettings
import serial.tools.list_ports #must explicitly import tools


try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    def _fromUtf8(s):
        return s

try:
    _encoding = QtGui.QApplication.UnicodeUTF8
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig)

class AThread(QtCore.QThread):
    updated = QtCore.pyqtSignal(str)

    def __init__(self):
        QtCore.QThread.__init__(self)

    def run(self):
        while True:
            if ser.in_waiting:
                line=ser.readline()[:-2]#remove end of line \r\n
                self.updated.emit(line.decode('utf-8'))  

class SettingsDialog(QtGui.QDialog):
    def __init__(self, parent=None):
        super(SettingsDialog, self).__init__(parent)

        self.setObjectName(_fromUtf8("settingsPopUp"))
        self.resize(331, 295)
        self.centralWidget = QtGui.QWidget(self)
        self.centralWidget.setObjectName(_fromUtf8("centralWidget"))
        self.verticalLayout = QtGui.QVBoxLayout(self.centralWidget)
        self.verticalLayout.setMargin(2)
        self.verticalLayout.setSpacing(1)
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.horizontalLayout = QtGui.QHBoxLayout()
        self.horizontalLayout.setMargin(2)
        self.horizontalLayout.setSpacing(1)
        self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
        self.label = QtGui.QLabel(self.centralWidget)
        self.label.setMinimumSize(QtCore.QSize(70, 0))
        self.label.setObjectName(_fromUtf8("label"))
        self.horizontalLayout.addWidget(self.label)
        self.portBox = QtGui.QComboBox(self.centralWidget)
        self.portBox.setMinimumSize(QtCore.QSize(150, 0))
        self.portBox.setObjectName(_fromUtf8("portBox"))
        self.horizontalLayout.addWidget(self.portBox)
        spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.horizontalLayout_2 = QtGui.QHBoxLayout()
        self.horizontalLayout_2.setMargin(2)
        self.horizontalLayout_2.setSpacing(1)
        self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
        self.label_2 = QtGui.QLabel(self.centralWidget)
        self.label_2.setMinimumSize(QtCore.QSize(70, 0))
        self.label_2.setObjectName(_fromUtf8("label_2"))
        self.horizontalLayout_2.addWidget(self.label_2)
        self.baudBox = QtGui.QComboBox(self.centralWidget)
        self.baudBox.setMinimumSize(QtCore.QSize(150, 0))
        self.baudBox.setObjectName(_fromUtf8("baudBox"))
        self.baudBox.addItem(_fromUtf8(""))
        self.baudBox.addItem(_fromUtf8(""))
        self.baudBox.addItem(_fromUtf8(""))
        self.baudBox.addItem(_fromUtf8(""))
        self.baudBox.addItem(_fromUtf8(""))
        self.baudBox.addItem(_fromUtf8(""))
        self.baudBox.addItem(_fromUtf8(""))
        self.baudBox.addItem(_fromUtf8(""))
        self.baudBox.addItem(_fromUtf8(""))
        self.baudBox.addItem(_fromUtf8(""))
        self.baudBox.addItem(_fromUtf8(""))
        self.baudBox.addItem(_fromUtf8(""))
        self.baudBox.addItem(_fromUtf8(""))
        self.baudBox.addItem(_fromUtf8(""))
        self.baudBox.addItem(_fromUtf8(""))
        self.horizontalLayout_2.addWidget(self.baudBox)
        spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.horizontalLayout_2.addItem(spacerItem1)
        self.verticalLayout.addLayout(self.horizontalLayout_2)
        self.horizontalLayout_3 = QtGui.QHBoxLayout()
        self.horizontalLayout_3.setMargin(2)
        self.horizontalLayout_3.setSpacing(1)
        self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3"))
        self.label_3 = QtGui.QLabel(self.centralWidget)
        self.label_3.setMinimumSize(QtCore.QSize(70, 0))
        self.label_3.setObjectName(_fromUtf8("label_3"))
        self.horizontalLayout_3.addWidget(self.label_3)
        self.dataBox = QtGui.QComboBox(self.centralWidget)
        self.dataBox.setMinimumSize(QtCore.QSize(150, 0))
        self.dataBox.setObjectName(_fromUtf8("dataBox"))
        self.dataBox.addItem(_fromUtf8(""))
        self.dataBox.addItem(_fromUtf8(""))
        self.horizontalLayout_3.addWidget(self.dataBox)
        spacerItem2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.horizontalLayout_3.addItem(spacerItem2)
        self.verticalLayout.addLayout(self.horizontalLayout_3)
        self.horizontalLayout_4 = QtGui.QHBoxLayout()
        self.horizontalLayout_4.setMargin(2)
        self.horizontalLayout_4.setSpacing(1)
        self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4"))
        self.label_4 = QtGui.QLabel(self.centralWidget)
        self.label_4.setMinimumSize(QtCore.QSize(70, 0))
        self.label_4.setObjectName(_fromUtf8("label_4"))
        self.horizontalLayout_4.addWidget(self.label_4)
        self.parityBox = QtGui.QComboBox(self.centralWidget)
        self.parityBox.setMinimumSize(QtCore.QSize(150, 0))
        self.parityBox.setObjectName(_fromUtf8("parityBox"))
        self.parityBox.addItem(_fromUtf8(""))
        self.parityBox.addItem(_fromUtf8(""))
        self.parityBox.addItem(_fromUtf8(""))
        self.parityBox.addItem(_fromUtf8(""))
        self.parityBox.addItem(_fromUtf8(""))
        self.horizontalLayout_4.addWidget(self.parityBox)
        spacerItem3 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.horizontalLayout_4.addItem(spacerItem3)
        self.verticalLayout.addLayout(self.horizontalLayout_4)
        self.horizontalLayout_5 = QtGui.QHBoxLayout()
        self.horizontalLayout_5.setMargin(2)
        self.horizontalLayout_5.setSpacing(1)
        self.horizontalLayout_5.setObjectName(_fromUtf8("horizontalLayout_5"))
        self.label_5 = QtGui.QLabel(self.centralWidget)
        self.label_5.setMinimumSize(QtCore.QSize(70, 0))
        self.label_5.setObjectName(_fromUtf8("label_5"))
        self.horizontalLayout_5.addWidget(self.label_5)
        self.stopBox = QtGui.QComboBox(self.centralWidget)
        self.stopBox.setMinimumSize(QtCore.QSize(150, 0))
        self.stopBox.setObjectName(_fromUtf8("stopBox"))
        self.stopBox.addItem(_fromUtf8(""))
        self.stopBox.addItem(_fromUtf8(""))
        self.stopBox.addItem(_fromUtf8(""))
        self.horizontalLayout_5.addWidget(self.stopBox)
        spacerItem4 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.horizontalLayout_5.addItem(spacerItem4)
        self.verticalLayout.addLayout(self.horizontalLayout_5)
        self.horizontalLayout_6 = QtGui.QHBoxLayout()
        self.horizontalLayout_6.setMargin(2)
        self.horizontalLayout_6.setSpacing(1)
        self.horizontalLayout_6.setObjectName(_fromUtf8("horizontalLayout_6"))
        self.label_6 = QtGui.QLabel(self.centralWidget)
        self.label_6.setMinimumSize(QtCore.QSize(70, 0))
        self.label_6.setObjectName(_fromUtf8("label_6"))
        self.horizontalLayout_6.addWidget(self.label_6)
        self.fcBox = QtGui.QComboBox(self.centralWidget)
        self.fcBox.setMinimumSize(QtCore.QSize(150, 0))
        self.fcBox.setObjectName(_fromUtf8("fcBox"))
        self.fcBox.addItem(_fromUtf8("1"))
        self.fcBox.addItem(_fromUtf8("2"))
        self.fcBox.addItem(_fromUtf8("3"))
        self.horizontalLayout_6.addWidget(self.fcBox)
        spacerItem5 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.horizontalLayout_6.addItem(spacerItem5)
        self.verticalLayout.addLayout(self.horizontalLayout_6)
        self.buttonBox = QtGui.QDialogButtonBox(self)
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
        self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
        self.verticalLayout.addWidget(self.buttonBox)
        self.setLayout(self.verticalLayout)
        self.retranslateUi(self)

    def retranslateUi(self, settingsPopUp):
        settingsPopUp.setWindowTitle(_translate("settingsPopUp", "settingsPopUp", None))
        self.label.setText(_translate("settingsPopUp", "COM Port", None))
        self.label_2.setText(_translate("settingsPopUp", "Baud Rate", None))
        self.baudBox.setItemText(0, _translate("settingsPopUp", "110", None))
        self.baudBox.setItemText(1, _translate("settingsPopUp", "300", None))
        self.baudBox.setItemText(2, _translate("settingsPopUp", "600", None))
        self.baudBox.setItemText(3, _translate("settingsPopUp", "1200", None))
        self.baudBox.setItemText(4, _translate("settingsPopUp", "2400", None))
        self.baudBox.setItemText(5, _translate("settingsPopUp", "4800", None))
        self.baudBox.setItemText(6, _translate("settingsPopUp", "9600", None))
        self.baudBox.setItemText(7, _translate("settingsPopUp", "14400", None))
        self.baudBox.setItemText(8, _translate("settingsPopUp", "19200", None))
        self.baudBox.setItemText(9, _translate("settingsPopUp", "38400", None))
        self.baudBox.setItemText(10, _translate("settingsPopUp", "57600", None))
        self.baudBox.setItemText(11, _translate("settingsPopUp", "115200", None))
        self.baudBox.setItemText(12, _translate("settingsPopUp", "230400", None))
        self.baudBox.setItemText(13, _translate("settingsPopUp", "460800", None))
        self.baudBox.setItemText(14, _translate("settingsPopUp", "921600", None))
        self.label_3.setText(_translate("settingsPopUp", "Data", None))
        self.dataBox.setItemText(0, _translate("settingsPopUp", "8 bit", None))
        self.dataBox.setItemText(1, _translate("settingsPopUp", "7 bit", None))
        self.label_4.setText(_translate("settingsPopUp", "Parity", None))
        self.parityBox.setItemText(0, _translate("settingsPopUp", "None", None))
        self.parityBox.setItemText(1, _translate("settingsPopUp", "Odd", None))
        self.parityBox.setItemText(2, _translate("settingsPopUp", "Even", None))
        self.parityBox.setItemText(3, _translate("settingsPopUp", "Mark", None))
        self.parityBox.setItemText(4, _translate("settingsPopUp", "Space", None))
        self.label_5.setText(_translate("settingsPopUp", "Stop", None))
        self.stopBox.setItemText(0, _translate("settingsPopUp", "1 bit", None))
        self.stopBox.setItemText(1, _translate("settingsPopUp", "1.5 bit", None))
        self.stopBox.setItemText(2, _translate("settingsPopUp", "2 bit", None))
        self.label_6.setText(_translate("settingsPopUp", "Flow Control", None))
        self.fcBox.setItemText(0, _translate("settingsPopUp", "None", None))
        self.fcBox.setItemText(1, _translate("settingsPopUp", "Xon/Xoff", None))
        self.fcBox.setItemText(2, _translate("settingsPopUp", "hardware", None))
        #self.closeButton.setText(_translate("settingsPopUp", "Close", None))

class New_Ui_MainWindow(Ui_MainWindow):
    def setupUi(self, MainWindow):
        Ui_MainWindow.setupUi(self,MainWindow)
        self.open_port.clicked.connect(self.start_serial)
        self.popup.clicked.connect(self.popupSettings)
        self.textBrowser.document().setMaximumBlockCount(5000)#number of lines before deleting.
        self.thread= AThread()
        self.thread.updated.connect(self.updateText) 
        #self.comboadd=serial.tools.list_ports.comports()
        #for port in self.comboadd:
        #    self.portBox.addItem(str(port))

    def updateText (self, text ):
        self.textBrowser.append(text)

    def start_serial(self):
        ser.baudrate = 115200
        ser.port = self.portBox.currentText()[:4]
        ser.timeout=.1
        ser.open()
        self.thread.start();

    def popupSettings(self):
        self.settings = SettingsDialog()
        self.settings.exec_()


if __name__ == "__main__":
    import sys
    import serial
    ser = serial.Serial()
    app = QtGui.QApplication(sys.argv)
    MainWindow = QtGui.QMainWindow()
    ui = New_Ui_MainWindow()
    ui.setupUi(MainWindow)

    MainWindow.show()
    sys.exit(app.exec_())
</code></pre>

<p>Generally, you would override the Qt Widget (i.e. <code>QMainWindow</code>) and not the class that Qt creator generates, but you can still do it the way you're doing if you want.  You just need to pass the parent <code>QMainWindow</code> to the Dialog.  Currently, you're not storing a reference to it.</p>

<pre><code>class New_Ui_MainWindow(Ui_MainWindow):
    def setupUi(self, MainWindow):
        self.MainWindow = MainWindow
        ...

    def popupSettings(self):
        self.settings = SettingsDialog(self.MainWindow)
        self.settings.exec_()
</code></pre>

<p>If you wanted to just use the generated dialog code. You could do this.  You</p>

<pre><code>from dialog import Ui_comSettings

class New_Ui_MainWindow(Ui_MainWindow):
    def setupUi(self, MainWindow):
        self.MainWindow = MainWindow
        ...

    def popupSettings(self):
        self.settings = QDialog(self.MainWindow)
        self.settings.ui = Ui_comSettings()
        self.settings.ui.setupUi(self.settings)
        self.settings.exec_()
</code></pre>

python pyqt pyqt4 qt-creator