Exemplo n.º 1
0
    def phil_list2gui(self, lst_phil_obj):

        sys_font = QFont()
        sys_font_point_size = sys_font.pointSize()

        inde_step = 4

        self.lst_label_widg = []
        self.lst_var_widg = []

        non_added_lst = []

        for nm, obj in enumerate(lst_phil_obj):

            if isinstance(obj, ScopeData):
                tmp_str = " " * int(obj.indent * inde_step) + str(obj.name)
                # print tmp_str
                tmp_widg = QLabel(tmp_str)
                tmp_widg.setAutoFillBackground(True)
                # tmp_widg.setPalette(self.plt_scp)
                tmp_widg.setFont(
                    QFont("Monospace", sys_font_point_size, QFont.Bold))
                tmp_widg.style_orign = "color: rgba(85, 85, 85, 255)"
                tmp_widg.setStyleSheet(tmp_widg.style_orign)

                tooltip = self._tooltip_from_phil_object(obj)
                if tooltip:
                    tmp_widg.setToolTip(tooltip)

                self.bg_box.addWidget(tmp_widg)

                tmp_widg.test_flag = "Yes"

                self.lst_label_widg.append(tmp_widg)

            else:

                tmp_h_box = QHBoxLayout()

                indent = str(obj.full_path()).count(".")
                tmp_str = " " * indent * inde_step + str(obj.name)
                tmp_label = QLabel(tmp_str)
                tmp_label.setAutoFillBackground(True)
                # tmp_label.setPalette(self.plt_obj)
                tmp_label.style_orign = "color: rgba(0, 0, 0, 255)"
                tmp_label.setStyleSheet(tmp_label.style_orign)
                tmp_label.setFont(QFont("Monospace", sys_font_point_size))

                tmp_h_box.addWidget(tmp_label)

                self.lst_label_widg.append(tmp_label)

                if obj.type.phil_type == "bool":

                    tmp_widg = MyQComboBox()
                    tmp_widg.tmp_lst = []
                    tmp_widg.tmp_lst.append("True")
                    tmp_widg.tmp_lst.append("False")
                    tmp_widg.tmp_lst.append("Auto")
                    # tmp_widg.setFocusPolicy(Qt.StrongFocus)
                    for lst_itm in tmp_widg.tmp_lst:
                        tmp_widg.addItem(lst_itm)

                    if str(obj.extract()) == "True":
                        tmp_widg.setCurrentIndex(0)
                        tmp_str += "                          True"

                    elif str(obj.extract()) == "False":
                        tmp_widg.setCurrentIndex(1)
                        tmp_str += "                          False"

                    elif str(obj.extract()) == "Auto":
                        tmp_widg.setCurrentIndex(2)
                        tmp_str += "                          Auto"

                    else:
                        tmp_str = None

                    # logger.info("tmp_widg.tmp_lst =", tmp_widg.tmp_lst)
                    # logger.info("tmp_str =", tmp_str)

                    tmp_widg.currentIndexChanged.connect(self.combobox_changed)

                elif obj.type.phil_type == "choice":
                    # remember to ask david about the issue here
                    # tmp_widg = QComboBox()

                    # tmp_widg.tmp_lst=[]
                    # pos = 0
                    # found_choise = False
                    # for num, opt in enumerate(obj.words):
                    #     opt = str(opt)
                    #     if(opt[0] == "*"):
                    #         found_choise = True
                    #         opt = opt[1:]
                    #         pos = num
                    #         tmp_str += "                          " + opt

                    #     tmp_widg.tmp_lst.append(opt)

                    # for lst_itm in tmp_widg.tmp_lst:
                    #     tmp_widg.addItem(lst_itm)

                    # tmp_widg.setCurrentIndex(pos)
                    # tmp_widg.currentIndexChanged.connect(self.combobox_changed)

                    # if(found_choise == False):
                    #     tmp_str = None
                    #     non_added_lst.append(str(obj.full_path()))
                    # begins pathed version
                    tmp_widg = MyQComboBox()

                    tmp_widg.tmp_lst = []
                    pos = 0
                    found_choise = False
                    for num, opt in enumerate(obj.words):
                        opt = str(opt)
                        if opt[0] == "*":
                            found_choise = True
                            opt = opt[1:]
                            pos = num
                            tmp_str += "                          " + opt

                        tmp_widg.tmp_lst.append(opt)

                    if not found_choise:
                        tmp_str += "                          " + str(
                            obj.extract())

                    for lst_itm in tmp_widg.tmp_lst:
                        tmp_widg.addItem(lst_itm)

                    tmp_widg.setCurrentIndex(pos)
                    tmp_widg.currentIndexChanged.connect(self.combobox_changed)

                    # ends pathed version

                else:
                    tmp_widg = QLineEdit()
                    tmp_widg.setText("")
                    tmp_widg.str_defl = None
                    tmp_widg.textChanged.connect(self.spnbox_changed)
                    # tmp_widg.tmp_lst = None
                    tmp_str += "                          " + str(
                        obj.extract())

                if tmp_str is not None:
                    tmp_widg.local_path = str(obj.full_path())
                    # tmp_h_box.addStretch()
                    tooltip = self._tooltip_from_phil_object(obj)
                    if tooltip:
                        tmp_widg.setToolTip(tooltip)
                    tmp_h_box.addWidget(tmp_widg)
                    self.lst_var_widg.append(tmp_widg)
                    self.bg_box.addLayout(tmp_h_box)

        # debugging = '''
        logger.debug("Non added parameters:")
        for lin_to_print in non_added_lst:
            logger.debug(lin_to_print)