collections.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:AlphaHooks 作者: AlphaHooks 项目源码 文件源码
def tree_widget(self, tree, structure):
        """
        Used to traverse a QTreeWidget and adding the items in a
        dict or list.

        :param tree: pass a QTreeWidget instance
        :param structure: pass a dictionary
        """
        if type(structure) is dict:
            for key, val in structure.items():
                child = QTreeWidgetItem()
                child.setText(0, key)
                tree.addChild(child)
                self.tree_widget(child, val)
        elif type(structure) is str:
            child = QTreeWidgetItem()
            child.setText(0, structure)
            tree.addChild(child)
        elif isinstance(structure, QWidget):
            self.index += 1
            tree.setText(1, str(self.index))
            self.display.addWidget(structure)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号