Ejemplo n.º 1
0
 def __init__(self, app):
     QtGui.QMainWindow.__init__(self)
     self.app = app
     self.ui = Ui_MainWindow()
     self.ui.setupUi(self)
     self.ui.actionAbout_Qt.triggered.connect(app.aboutQt)
     self.ui.actionQuit.triggered.connect(self.quit)
     self.ui.quitBtn.clicked.connect(self.quit)
     self.ui.moduleNotebook.currentChanged.connect(self.updateWizButtons)
     self.ui.nextBtn.clicked.connect(self.nextTab)
     self.ui.prevBtn.clicked.connect(self.prevTab)
     self.welcome_container = QtGui.QWidget()
     self.welcomeTab = Ui_Welcome()
     self.welcomeTab.setupUi(self.welcome_container)
     self.ui.moduleNotebook.insertTab(0, self.welcome_container, "Welcome")
     self.createConfigTab()
     self.updateWizButtons()
Ejemplo n.º 2
0
 def __init__(self, app):
     QtGui.QMainWindow.__init__(self)
     self.app = app
     self.ui = Ui_MainWindow()
     self.ui.setupUi(self)
     self.ui.actionAbout_Qt.triggered.connect(app.aboutQt)
     self.ui.actionQuit.triggered.connect(self.quit)
     self.ui.quitBtn.clicked.connect(self.quit)
     self.ui.moduleNotebook.currentChanged.connect(self.updateWizButtons)
     self.ui.nextBtn.clicked.connect(self.nextTab)
     self.ui.prevBtn.clicked.connect(self.prevTab)
     self.welcome_container = QtGui.QWidget()
     self.welcomeTab = Ui_Welcome()
     self.welcomeTab.setupUi(self.welcome_container)
     self.ui.moduleNotebook.insertTab(0, self.welcome_container, "Welcome")
     self.createConfigTab()
     self.updateWizButtons()
Ejemplo n.º 3
0
class GUI(QtGui.QMainWindow):
    def __init__(self, app):
        QtGui.QMainWindow.__init__(self)
        self.app = app
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.actionAbout_Qt.triggered.connect(app.aboutQt)
        self.ui.actionQuit.triggered.connect(self.quit)
        self.ui.quitBtn.clicked.connect(self.quit)
        self.ui.moduleNotebook.currentChanged.connect(self.updateWizButtons)
        self.ui.nextBtn.clicked.connect(self.nextTab)
        self.ui.prevBtn.clicked.connect(self.prevTab)
        self.welcome_container = QtGui.QWidget()
        self.welcomeTab = Ui_Welcome()
        self.welcomeTab.setupUi(self.welcome_container)
        self.ui.moduleNotebook.insertTab(0, self.welcome_container, "Welcome")
        self.createConfigTab()
        self.updateWizButtons()

    def updateWizButtons(self):
        if self.ui.moduleNotebook.currentIndex() <= 0:
            self.ui.prevBtn.setEnabled(False)
        else:
            self.ui.prevBtn.setEnabled(True)
        if self.isLast():
            self.ui.nextBtn.setText(_("Finish"))
        else:
            self.ui.nextBtn.setText(_("Next"))
        if self.ui.moduleNotebook.currentIndex() < 0:
            self.ui.nextBtn.setEnabled(False)
        else:
            self.ui.nextBtn.setEnabled(True)

    def nextTab(self, *args):
        if self.isLast():
            self.quit()
        else:
            self.chTab(1)

    def prevTab(self, *args):
        self.chTab(-1)

    def chTab(self, amt):
        self.ui.moduleNotebook.setCurrentIndex(
            self.ui.moduleNotebook.currentIndex() + amt)

    def isLast(self):
        return self.ui.moduleNotebook.count(
        ) - 1 <= self.ui.moduleNotebook.currentIndex()

    def createConfigTab(self):
        configs = config.Configuration
        self.configTab = QtGui.QWidget()
        self.configTab.vlayout = QtGui.QVBoxLayout(self.configTab)
        # Master notebook (stores the sections)
        self.configTab.notebook1 = QtGui.QTabWidget(self.configTab)
        self.configTab.vlayout.addWidget(self.configTab.notebook1)
        self.fillConfiguration(configs, self.configTab)
        self.ui.moduleNotebook.addTab(self.configTab, "Configuration")

    def fillConfiguration(self, configs, widget):
        # TODO: Clean this mess, or at least comment it
        l = chr(108)
        v = chr(118)
        for i in configs.keys():
            # If the section is not in the notebook, add it
            if not i in self.configTab.notebook1.__dict__:
                self.configTab.notebook1.__dict__[i] = QtGui.QWidget()
                self.configTab.notebook1.__dict__[
                    i].vlayout = QtGui.QVBoxLayout(
                        self.configTab.notebook1.__dict__[i])
                self.configTab.notebook1.__dict__[i].nbook = QtGui.QTabWidget(
                    self.configTab.notebook1.__dict__[i])
                self.configTab.notebook1.__dict__[i].vlayout.addWidget(
                    self.configTab.notebook1.__dict__[i].nbook)
                self.configTab.notebook1.addTab(
                    self.configTab.notebook1.__dict__[i], i)
            for x in configs[i].keys():
                c = configutils.getValueP(configs[i][x], configutils.category)
                n = configutils.getValueP(configs[i][x], configutils.name)
                t = configutils.getValueP(configs[i][x], configutils.types)
                v_ = configutils.getValue(configs[i][x])
                c_ = configutils.getChoices(t)
                var = (i, x)
                # If the category is not in the section's notebook, add it
                if not c in self.configTab.notebook1.__dict__[i].nbook.__dict__:
                    fw = QtGui.QWidget(
                        self.configTab.notebook1.__dict__[i].nbook)
                    vb = QtGui.QVBoxLayout(fw)
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[
                        c] = QtGui.QScrollArea(fw)
                    vb.addWidget(
                        self.configTab.notebook1.__dict__[i].nbook.__dict__[c])
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[
                        c].setWidgetResizable(False)
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[
                        c].flayout = QtGui.QFormLayout()
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[
                        c].flayout.setSizeConstraint(
                            QtGui.QLayout.SetFixedSize)
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[
                        c].flayout.setFieldGrowthPolicy(
                            QtGui.QFormLayout.AllNonFixedFieldsGrow)
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[
                        c].flayout.setLabelAlignment(QtCore.Qt.AlignLeft)
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[
                        c].flayoutC = QtGui.QWidget()
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[
                        c].flayoutC.setLayout(
                            self.configTab.notebook1.__dict__[i].nbook.
                            __dict__[c].flayout)
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[
                        c].setWidget(self.configTab.notebook1.__dict__[i].
                                     nbook.__dict__[c].flayoutC)
                    self.configTab.notebook1.__dict__[i].nbook.addTab(fw, c)
                # Add the label
                self.configTab.notebook1.__dict__[i].nbook.__dict__[
                    c].__dict__[n] = {}
                self.configTab.notebook1.__dict__[i].nbook.__dict__[
                    c].__dict__[n][l] = QtGui.QLabel()
                self.configTab.notebook1.__dict__[i].nbook.__dict__[
                    c].__dict__[n][l].setText(n)
                # Add the value
                if t == configutils.yesno:
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[
                        c].__dict__[n][v] = ConfigWidget(
                            QtGui.QCheckBox(), var)
                    if configutils.parseBoolean(v_):
                        self.configTab.notebook1.__dict__[i].nbook.__dict__[
                            c].__dict__[n][v].widget.setChecked(True)
                elif c_ is not None and len(c_) > 0:
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[
                        c].__dict__[n][v] = ConfigWidget(
                            QtGui.QComboBox(), var)
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[
                        c].__dict__[n][v].widget.clear()
                    c__ = 0
                    for y in c_:
                        self.configTab.notebook1.__dict__[i].nbook.__dict__[
                            c].__dict__[n][v].widget.addItem(y)
                        if y == v_:
                            self.configTab.notebook1.__dict__[
                                i].nbook.__dict__[c].__dict__[n][
                                    v].widget.setCurrentIndex(c__)
                        c__ += 1
                else:
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[
                        c].__dict__[n][v] = ConfigWidget(
                            QtGui.QLineEdit(), var)
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[
                        c].__dict__[n][v].widget.setText(v_)
                self.configTab.notebook1.__dict__[i].nbook.__dict__[
                    c].__dict__[n][v].widget.setSizePolicy(
                        QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding))
                self.configTab.notebook1.__dict__[i].nbook.__dict__[
                    c].flayout.addRow(
                        self.configTab.notebook1.__dict__[i].nbook.__dict__[c].
                        __dict__[n][l], self.configTab.notebook1.__dict__[i].
                        nbook.__dict__[c].__dict__[n][v].widget)

    def addTab(self, *args):
        self.ui.moduleNotebook.addTab(*args)
        self.updateWizButtons()

    def quit(self, *args):
        quitProg(self.app)
Ejemplo n.º 4
0
class GUI(QtGui.QMainWindow):
    def __init__(self, app):
        QtGui.QMainWindow.__init__(self)
        self.app = app
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.actionAbout_Qt.triggered.connect(app.aboutQt)
        self.ui.actionQuit.triggered.connect(self.quit)
        self.ui.quitBtn.clicked.connect(self.quit)
        self.ui.moduleNotebook.currentChanged.connect(self.updateWizButtons)
        self.ui.nextBtn.clicked.connect(self.nextTab)
        self.ui.prevBtn.clicked.connect(self.prevTab)
        self.welcome_container = QtGui.QWidget()
        self.welcomeTab = Ui_Welcome()
        self.welcomeTab.setupUi(self.welcome_container)
        self.ui.moduleNotebook.insertTab(0, self.welcome_container, "Welcome")
        self.createConfigTab()
        self.updateWizButtons()

    def updateWizButtons(self):
        if self.ui.moduleNotebook.currentIndex() <= 0:
            self.ui.prevBtn.setEnabled(False)
        else:
            self.ui.prevBtn.setEnabled(True)
        if self.isLast():
            self.ui.nextBtn.setText(_("Finish"))
        else:
            self.ui.nextBtn.setText(_("Next"))
        if self.ui.moduleNotebook.currentIndex() < 0:
            self.ui.nextBtn.setEnabled(False)
        else:
            self.ui.nextBtn.setEnabled(True)

    def nextTab(self, *args):
        if self.isLast():
            self.quit()
        else:
            self.chTab(1)

    def prevTab(self, *args):
        self.chTab(-1)

    def chTab(self, amt):
        self.ui.moduleNotebook.setCurrentIndex(self.ui.moduleNotebook.currentIndex() + amt)

    def isLast(self):
        return self.ui.moduleNotebook.count() - 1 <= self.ui.moduleNotebook.currentIndex()

    def createConfigTab(self):
        configs = config.Configuration
        self.configTab = QtGui.QWidget()
        self.configTab.vlayout = QtGui.QVBoxLayout(self.configTab)
        # Master notebook (stores the sections)
        self.configTab.notebook1 = QtGui.QTabWidget(self.configTab)
        self.configTab.vlayout.addWidget(self.configTab.notebook1)
        self.fillConfiguration(configs, self.configTab)
        self.ui.moduleNotebook.addTab(self.configTab, "Configuration")

    def fillConfiguration(self, configs, widget):
        # TODO: Clean this mess, or at least comment it
        l = chr(108)
        v = chr(118)
        for i in configs.keys():
            # If the section is not in the notebook, add it
            if not i in self.configTab.notebook1.__dict__:
                self.configTab.notebook1.__dict__[i] = QtGui.QWidget()
                self.configTab.notebook1.__dict__[i].vlayout = QtGui.QVBoxLayout(
                                                                self.configTab.notebook1.__dict__[i])
                self.configTab.notebook1.__dict__[i].nbook = QtGui.QTabWidget(
                                                                self.configTab.notebook1.__dict__[i])
                self.configTab.notebook1.__dict__[i].vlayout.addWidget(
                                                        self.configTab.notebook1.__dict__[i].nbook)
                self.configTab.notebook1.addTab(self.configTab.notebook1.__dict__[i], i)
            for x in configs[i].keys():
                c = configutils.getValueP(configs[i][x], configutils.category)
                n = configutils.getValueP(configs[i][x], configutils.name)
                t = configutils.getValueP(configs[i][x], configutils.types)
                v_ = configutils.getValue(configs[i][x])
                c_ = configutils.getChoices(t)
                var = (i, x)
                # If the category is not in the section's notebook, add it
                if not c in self.configTab.notebook1.__dict__[i].nbook.__dict__:
                    fw = QtGui.QWidget(self.configTab.notebook1.__dict__[i].nbook)
                    vb = QtGui.QVBoxLayout(fw)
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[c] = QtGui.QScrollArea(fw)
                    vb.addWidget(self.configTab.notebook1.__dict__[i].nbook.__dict__[c])
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[c].setWidgetResizable(False)
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayout = QtGui.QFormLayout()
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayout.setSizeConstraint(
                                                                QtGui.QLayout.SetFixedSize)
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayout.setFieldGrowthPolicy(
                                                        QtGui.QFormLayout.AllNonFixedFieldsGrow)
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayout.setLabelAlignment(
                                                                        QtCore.Qt.AlignLeft)
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayoutC = QtGui.QWidget()
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayoutC.setLayout(
                            self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayout)
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[c].setWidget(
                            self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayoutC)
                    self.configTab.notebook1.__dict__[i].nbook.addTab(
                                        fw, c)
                # Add the label
                self.configTab.notebook1.__dict__[i].nbook.__dict__[c].__dict__[n] = {}
                self.configTab.notebook1.__dict__[i].nbook.__dict__[c].__dict__[n][l] = QtGui.QLabel()
                self.configTab.notebook1.__dict__[i].nbook.__dict__[c].__dict__[n][l].setText(n)
                # Add the value
                if t == configutils.yesno:
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[c].__dict__[n][v] = ConfigWidget(QtGui.QCheckBox(), var)
                    if configutils.parseBoolean(v_):
                        self.configTab.notebook1.__dict__[i].nbook.__dict__[c].__dict__[n][v].widget.setChecked(True)
                elif c_ is not None and len(c_) > 0:
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[c].__dict__[n][v] = ConfigWidget(QtGui.QComboBox(), var)
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[c].__dict__[n][v].widget.clear()
                    c__ = 0
                    for y in c_:
                        self.configTab.notebook1.__dict__[i].nbook.__dict__[c].__dict__[n][v].widget.addItem(y)
                        if y == v_:
                            self.configTab.notebook1.__dict__[i].nbook.__dict__[c].__dict__[n][v].widget.setCurrentIndex(c__)
                        c__ += 1
                else:
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[c].__dict__[n][v] = ConfigWidget(QtGui.QLineEdit(), var)
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[c].__dict__[n][v].widget.setText(v_)
                self.configTab.notebook1.__dict__[i].nbook.__dict__[c].__dict__[n][v].widget.setSizePolicy(
                                    QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding))
                self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayout.addRow(
                        self.configTab.notebook1.__dict__[i].nbook.__dict__[c].__dict__[n][l],
                        self.configTab.notebook1.__dict__[i].nbook.__dict__[c].__dict__[n][v].widget)

    def addTab(self, *args):
        self.ui.moduleNotebook.addTab(*args)
        self.updateWizButtons()

    def quit(self, *args):
        quitProg(self.app)
Ejemplo n.º 5
0
class GUI(QtGui.QMainWindow):
    def __init__(self, app):
        QtGui.QMainWindow.__init__(self)
        self.app = app
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.actionAbout_Qt.triggered.connect(app.aboutQt)
        self.ui.actionAbout.triggered.connect(self.showAbout)
        self.ui.actionQuit.triggered.connect(self.quit)
        self.ui.quitBtn.clicked.connect(self.quit)
        self.ui.moduleNotebook.currentChanged.connect(self.updateWizButtons)
        self.ui.nextBtn.clicked.connect(self.nextTab)
        self.ui.prevBtn.clicked.connect(self.prevTab)
        self.welcome_container = QtGui.QWidget()
        self.welcomeTab = Ui_Welcome()
        self.welcomeTab.setupUi(self.welcome_container)
        self.ui.moduleNotebook.insertTab(0, self.welcome_container, "Welcome")
        self.createConfigTab()
        self.updateWizButtons()

    def updateWizButtons(self):
        if self.ui.moduleNotebook.currentIndex() <= 0:
            self.ui.prevBtn.setEnabled(False)
        else:
            self.ui.prevBtn.setEnabled(True)
        if self.isLast():
            self.ui.nextBtn.setText(_("Finish"))
        else:
            self.ui.nextBtn.setText(_("Next"))
        if self.ui.moduleNotebook.currentIndex() < 0:
            self.ui.nextBtn.setEnabled(False)
        else:
            self.ui.nextBtn.setEnabled(True)

    def nextTab(self, *args):
        if self.isLast():
            self.quit()
        else:
            self.chTab(1)

    def prevTab(self, *args):
        self.chTab(-1)

    def chTab(self, amt):
        self.ui.moduleNotebook.setCurrentIndex(
            self.ui.moduleNotebook.currentIndex() + amt)

    def isLast(self):
        return self.ui.moduleNotebook.count(
        ) - 1 <= self.ui.moduleNotebook.currentIndex()

    def createConfigTab(self):
        configs = config.Configuration
        self.configTab = QtGui.QWidget()
        self.configTab.vlayout = QtGui.QVBoxLayout(self.configTab)
        # Master notebook (stores the sections)
        self.configTab.notebook1 = QtGui.QTabWidget(self.configTab)
        self.configTab.vlayout.addWidget(self.configTab.notebook1)
        self.fillConfiguration(configs, self.configTab)
        self.ui.moduleNotebook.addTab(self.configTab, _("Configuration"))

    def addCategory(self, section, category):
        i = section
        c = category
        fw = QtGui.QWidget(self.configTab.notebook1.__dict__[i].nbook)
        vb = QtGui.QVBoxLayout(fw)
        self.configTab.notebook1.__dict__[i].nbook.__dict__[
            c] = QtGui.QScrollArea(fw)
        vb.addWidget(self.configTab.notebook1.__dict__[i].nbook.__dict__[c])
        self.configTab.notebook1.__dict__[i].nbook.__dict__[
            c].setWidgetResizable(True)
        self.configTab.notebook1.__dict__[i].nbook.__dict__[
            c].flayout = QtGui.QFormLayout()
        #self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayout.setSizeConstraint(
        #                                            QtGui.QLayout.SetFixedSize)
        self.configTab.notebook1.__dict__[i].nbook.__dict__[
            c].flayout.setFieldGrowthPolicy(
                QtGui.QFormLayout.ExpandingFieldsGrow)
        self.configTab.notebook1.__dict__[i].nbook.__dict__[
            c].flayout.setLabelAlignment(QtCore.Qt.AlignLeft)
        #self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayout.setFormAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignTop);
        self.configTab.notebook1.__dict__[i].nbook.__dict__[
            c].flayoutC = QtGui.QWidget()
        self.configTab.notebook1.__dict__[i].nbook.__dict__[
            c].flayoutC.setLayout(
                self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayout)
        self.configTab.notebook1.__dict__[i].nbook.__dict__[
            c].flayoutC.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding,
                                      QtGui.QSizePolicy.Preferred)
        self.configTab.notebook1.__dict__[i].nbook.__dict__[c].setWidget(
            self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayoutC)
        self.configTab.notebook1.__dict__[i].nbook.addTab(fw, c)

    def fillConfiguration(self, configs, widget):
        # TODO: Clean this mess, or at least comment it
        l = "l"
        v = "v"
        for i in configs.keys():
            # If the section is not in the notebook, add it
            if not i in self.configTab.notebook1.__dict__:
                self.configTab.notebook1.__dict__[i] = QtGui.QWidget()
                self.configTab.notebook1.__dict__[
                    i].vlayout = QtGui.QVBoxLayout(
                        self.configTab.notebook1.__dict__[i])
                self.configTab.notebook1.__dict__[i].nbook = QtGui.QTabWidget(
                    self.configTab.notebook1.__dict__[i])
                self.configTab.notebook1.__dict__[i].vlayout.addWidget(
                    self.configTab.notebook1.__dict__[i].nbook)
                self.configTab.notebook1.addTab(
                    self.configTab.notebook1.__dict__[i], i)
            for c in configutils.getValue(configs[i][configutils.categories]):
                self.addCategory(i, c)
            for x in configs[i].keys():
                if x == configutils.categories:
                    continue
                c = configutils.getValueP(configs[i][x], configutils.category)
                n = configutils.getValueP(configs[i][x], configutils.name)
                t = configutils.getValueP(configs[i][x], configutils.types)
                d = configutils.getValueP(configs[i][x], configutils.desc)
                v_ = configutils.getValue(configs[i][x])
                c_ = configutils.getChoices(t)
                var = (i, x)
                uw = True
                # If the category is not in the section's notebook, add it
                if not c in self.configTab.notebook1.__dict__[i].nbook.__dict__:
                    self.addCategory(i, c)
                # Add the dictionary
                self.configTab.notebook1.__dict__[i].nbook.__dict__[
                    c].__dict__[n] = {}
                # Add the label
                self.configTab.notebook1.__dict__[i].nbook.__dict__[
                    c].__dict__[n][l] = QtGui.QLabel()
                self.configTab.notebook1.__dict__[i].nbook.__dict__[
                    c].__dict__[n][l].setText(n)
                self.configTab.notebook1.__dict__[i].nbook.__dict__[
                    c].__dict__[n][l].setToolTip(d)
                # Add the value
                if t == configutils.yesno:
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[
                        c].__dict__[n][v] = ConfigWidget(
                            QtGui.QCheckBox(), var)
                    if v_:
                        self.configTab.notebook1.__dict__[i].nbook.__dict__[
                            c].__dict__[n][v].widget.setChecked(True)
                elif c_ is not None and len(c_) > 0:
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[
                        c].__dict__[n][v] = ConfigWidget(
                            QtGui.QComboBox(), var)
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[
                        c].__dict__[n][v].widget.clear()
                    c__ = 0
                    for y in c_:
                        self.configTab.notebook1.__dict__[i].nbook.__dict__[
                            c].__dict__[n][v].widget.addItem(y)
                        if y == v_:
                            self.configTab.notebook1.__dict__[
                                i].nbook.__dict__[c].__dict__[n][
                                    v].widget.setCurrentIndex(c__)
                        c__ += 1
                elif t == configutils.multiple:
                    if not isinstance(v_, list):
                        # Wut?
                        logger.logE(self.tn, logger.E,
                                    _("Something went wrong"))
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[
                        c].__dict__[n][v] = MultipleValues(var)
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[
                        c].__dict__[n][v].set(v_)
                    uw = False
                elif t == configutils.filename:
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[
                        c].__dict__[n][v] = FileName(var)
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[
                        c].__dict__[n][v].set(v_)
                    uw = False
                else:
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[
                        c].__dict__[n][v] = ConfigWidget(
                            QtGui.QLineEdit(), var)
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[
                        c].__dict__[n][v].widget.setText(v_)
                #self.configTab.notebook1.__dict__[i].nbook.__dict__[c].__dict__[n][v].widget.setSizePolicy(
                #                    QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding))
                if uw:
                    p = self.configTab.notebook1.__dict__[i].nbook.__dict__[
                        c].__dict__[n][v].widget
                else:
                    p = self.configTab.notebook1.__dict__[i].nbook.__dict__[
                        c].__dict__[n][v]
                p.setToolTip(d)
                self.configTab.notebook1.__dict__[i].nbook.__dict__[
                    c].flayout.addRow(
                        self.configTab.notebook1.__dict__[i].nbook.__dict__[c].
                        __dict__[n][l], p)

    def addTab(self, *args):
        self.ui.moduleNotebook.addTab(*args)
        self.updateWizButtons()

    def showAbout(self):
        QtGui.QMessageBox.about(self, config.product, config.about_string)

    def quit(self, *args):
        quitProg(self.app)
Ejemplo n.º 6
0
class GUI(QtGui.QMainWindow):
    def __init__(self, app):
        QtGui.QMainWindow.__init__(self)
        self.app = app
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.actionAbout_Qt.triggered.connect(app.aboutQt)
        self.ui.actionAbout.triggered.connect(self.showAbout)
        self.ui.actionQuit.triggered.connect(self.quit)
        self.ui.quitBtn.clicked.connect(self.quit)
        self.ui.moduleNotebook.currentChanged.connect(self.updateWizButtons)
        self.ui.nextBtn.clicked.connect(self.nextTab)
        self.ui.prevBtn.clicked.connect(self.prevTab)
        self.welcome_container = QtGui.QWidget()
        self.welcomeTab = Ui_Welcome()
        self.welcomeTab.setupUi(self.welcome_container)
        self.ui.moduleNotebook.insertTab(0, self.welcome_container, "Welcome")
        self.createConfigTab()
        self.updateWizButtons()

    def updateWizButtons(self):
        if self.ui.moduleNotebook.currentIndex() <= 0:
            self.ui.prevBtn.setEnabled(False)
        else:
            self.ui.prevBtn.setEnabled(True)
        if self.isLast():
            self.ui.nextBtn.setText(_("Finish"))
        else:
            self.ui.nextBtn.setText(_("Next"))
        if self.ui.moduleNotebook.currentIndex() < 0:
            self.ui.nextBtn.setEnabled(False)
        else:
            self.ui.nextBtn.setEnabled(True)

    def nextTab(self, *args):
        if self.isLast():
            self.quit()
        else:
            self.chTab(1)

    def prevTab(self, *args):
        self.chTab(-1)

    def chTab(self, amt):
        self.ui.moduleNotebook.setCurrentIndex(
            self.ui.moduleNotebook.currentIndex() + amt)

    def isLast(self):
        return self.ui.moduleNotebook.count() - 1 <= self.ui.moduleNotebook.currentIndex()

    def createConfigTab(self):
        configs = config.Configuration
        self.configTab = QtGui.QWidget()
        self.configTab.vlayout = QtGui.QVBoxLayout(self.configTab)
        # Master notebook (stores the sections)
        self.configTab.notebook1 = QtGui.QTabWidget(self.configTab)
        self.configTab.vlayout.addWidget(self.configTab.notebook1)
        self.fillConfiguration(configs, self.configTab)
        self.ui.moduleNotebook.addTab(self.configTab, _("Configuration"))

    def addCategory(self, section, category):
        i = section
        c = category
        fw = QtGui.QWidget(self.configTab.notebook1.__dict__[i].nbook)
        vb = QtGui.QVBoxLayout(fw)
        self.configTab.notebook1.__dict__[i].nbook.__dict__[
            c] = QtGui.QScrollArea(fw)
        vb.addWidget(self.configTab.notebook1.__dict__[i].nbook.__dict__[c])
        self.configTab.notebook1.__dict__[i].nbook.__dict__[
            c].setWidgetResizable(True)
        self.configTab.notebook1.__dict__[i].nbook.__dict__[
            c].flayout = QtGui.QFormLayout()
        #self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayout.setSizeConstraint(
        #                                            QtGui.QLayout.SetFixedSize)
        self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayout.setFieldGrowthPolicy(
            QtGui.QFormLayout.ExpandingFieldsGrow)
        self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayout.setLabelAlignment(
            QtCore.Qt.AlignLeft)
        #self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayout.setFormAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignTop);
        self.configTab.notebook1.__dict__[i].nbook.__dict__[
            c].flayoutC = QtGui.QWidget()
        self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayoutC.setLayout(
            self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayout)
        self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayoutC.setSizePolicy(
            QtGui.QSizePolicy.MinimumExpanding,
            QtGui.QSizePolicy.Preferred)
        self.configTab.notebook1.__dict__[i].nbook.__dict__[c].setWidget(
            self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayoutC)
        self.configTab.notebook1.__dict__[i].nbook.addTab(
            fw, c)

    def fillConfiguration(self, configs, widget):
        # TODO: Clean this mess, or at least comment it
        l = "l"
        v = "v"
        for i in configs.keys():
            # If the section is not in the notebook, add it
            if not i in self.configTab.notebook1.__dict__:
                self.configTab.notebook1.__dict__[i] = QtGui.QWidget()
                self.configTab.notebook1.__dict__[i].vlayout = QtGui.QVBoxLayout(
                    self.configTab.notebook1.__dict__[i])
                self.configTab.notebook1.__dict__[i].nbook = QtGui.QTabWidget(
                    self.configTab.notebook1.__dict__[i])
                self.configTab.notebook1.__dict__[i].vlayout.addWidget(
                    self.configTab.notebook1.__dict__[i].nbook)
                self.configTab.notebook1.addTab(
                    self.configTab.notebook1.__dict__[i], i)
            for c in configutils.getValue(configs[i][configutils.categories]):
                self.addCategory(i, c)
            for x in configs[i].keys():
                if x == configutils.categories:
                    continue
                c = configutils.getValueP(configs[i][x], configutils.category)
                n = configutils.getValueP(configs[i][x], configutils.name)
                t = configutils.getValueP(configs[i][x], configutils.types)
                d = configutils.getValueP(configs[i][x], configutils.desc)
                v_ = configutils.getValue(configs[i][x])
                c_ = configutils.getChoices(t)
                var = (i, x)
                uw = True
                # If the category is not in the section's notebook, add it
                if not c in self.configTab.notebook1.__dict__[i].nbook.__dict__:
                    self.addCategory(i, c)
                # Add the dictionary
                self.configTab.notebook1.__dict__[
                    i].nbook.__dict__[c].__dict__[n] = {}
                # Add the label
                self.configTab.notebook1.__dict__[
                    i].nbook.__dict__[c].__dict__[n][l] = QtGui.QLabel()
                self.configTab.notebook1.__dict__[
                    i].nbook.__dict__[c].__dict__[n][l].setText(n)
                self.configTab.notebook1.__dict__[
                    i].nbook.__dict__[c].__dict__[n][l].setToolTip(d)
                # Add the value
                if t == configutils.yesno:
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[c].__dict__[n][v] = ConfigWidget(QtGui.QCheckBox(), var)
                    if v_:
                        self.configTab.notebook1.__dict__[i].nbook.__dict__[
                            c].__dict__[n][v].widget.setChecked(True)
                elif c_ is not None and len(c_) > 0:
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[c].__dict__[n][v] = ConfigWidget(QtGui.QComboBox(), var)
                    self.configTab.notebook1.__dict__[
                        i].nbook.__dict__[c].__dict__[n][v].widget.clear()
                    c__ = 0
                    for y in c_:
                        self.configTab.notebook1.__dict__[i].nbook.__dict__[
                            c].__dict__[n][v].widget.addItem(y)
                        if y == v_:
                            self.configTab.notebook1.__dict__[i].nbook.__dict__[c].__dict__[n][v].widget.setCurrentIndex(c__)
                        c__ += 1
                elif t == configutils.multiple:
                    if not isinstance(v_, list):
                        # Wut?
                        logger.logE(
                            self.tn, logger.E, _("Something went wrong"))
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[
                        c].__dict__[n][v] = MultipleValues(var)
                    self.configTab.notebook1.__dict__[
                        i].nbook.__dict__[c].__dict__[n][v].set(v_)
                    uw = False
                elif t == configutils.filename:
                    self.configTab.notebook1.__dict__[
                        i].nbook.__dict__[c].__dict__[n][v] = FileName(var)
                    self.configTab.notebook1.__dict__[
                        i].nbook.__dict__[c].__dict__[n][v].set(v_)
                    uw = False
                else:
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[c].__dict__[n][v] = ConfigWidget(QtGui.QLineEdit(), var)
                    self.configTab.notebook1.__dict__[
                        i].nbook.__dict__[c].__dict__[n][v].widget.setText(v_)
                #self.configTab.notebook1.__dict__[i].nbook.__dict__[c].__dict__[n][v].widget.setSizePolicy(
                #                    QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding))
                if uw:
                    p = self.configTab.notebook1.__dict__[
                        i].nbook.__dict__[c].__dict__[n][v].widget
                else:
                    p = self.configTab.notebook1.__dict__[
                        i].nbook.__dict__[c].__dict__[n][v]
                p.setToolTip(d)
                self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayout.addRow(
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[c].__dict__[n][l], p)

    def addTab(self, *args):
        self.ui.moduleNotebook.addTab(*args)
        self.updateWizButtons()

    def showAbout(self):
        QtGui.QMessageBox.about(self, config.product, config.about_string)

    def quit(self, *args):
        quitProg(self.app)