Example #1
0
    def __init__(self,
                 data,
                 title="",
                 comment="",
                 icon=None,
                 parent=None,
                 apply=None):
        QtGui.QDialog.__init__(self, parent)

        self.apply_callback = apply

        # Form
        if isinstance(data[0][0], (list, tuple)):
            self.formwidget = FormTabWidget(data, comment=comment, parent=self)
        elif len(data[0]) == 3:
            self.formwidget = FormComboWidget(data,
                                              comment=comment,
                                              parent=self)
        else:
            self.formwidget = FormWidget(data, comment=comment, parent=self)
        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.formwidget)

        self.float_fields = []
        self.formwidget.setup()

        # Button box
        self.bbox = bbox = QtGui.QDialogButtonBox(
            QtGui.QDialogButtonBox.Ok
            | QtGui.QDialogButtonBox.Cancel)
        self.connect(self.formwidget, QtCore.SIGNAL('update_buttons()'),
                     self.update_buttons)
        if self.apply_callback is not None:
            apply_btn = bbox.addButton(QtGui.QDialogButtonBox.Apply)
            self.connect(apply_btn, QtCore.SIGNAL("clicked()"), self.apply)
        self.connect(bbox, QtCore.SIGNAL("accepted()"),
                     QtCore.SLOT("accept()"))
        self.connect(bbox, QtCore.SIGNAL("rejected()"),
                     QtCore.SLOT("reject()"))
        layout.addWidget(bbox)

        self.setLayout(layout)

        self.setWindowTitle(title)
        if not isinstance(icon, QtGui.QIcon):
            icon = QtGui.QWidget().style().standardIcon(
                QtGui.QStyle.SP_MessageBoxQuestion)
        self.setWindowIcon(icon)
Example #2
0
    def __init__(self, datalist, comment="", parent=None):
        QtGui.QWidget.__init__(self, parent)
        layout = QtGui.QVBoxLayout()
        self.setLayout(layout)
        self.combobox = QtGui.QComboBox()
        layout.addWidget(self.combobox)

        self.stackwidget = QtGui.QStackedWidget(self)
        layout.addWidget(self.stackwidget)
        self.connect(self.combobox, QtCore.SIGNAL("currentIndexChanged(int)"),
                     self.stackwidget, QtCore.SLOT("setCurrentIndex(int)"))

        self.widgetlist = []
        for data, title, comment in datalist:
            self.combobox.addItem(title)
            widget = FormWidget(data, comment=comment, parent=self)
            self.stackwidget.addWidget(widget)
            self.widgetlist.append(widget)