configwindow.py 文件源码

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

项目:dxf2gcode 作者: cnc-club 项目源码 文件源码
def __init__(self, text, columns = None, parent = None):
        """
        Initialization of the CfgTable class (editable 2D table).
        @param text: text string associated with the table
        @param columns: string list containing all the columns names
        """
        QWidget.__init__(self, parent)

        self.tablewidget = QTableWidget(parent)
        self.tablewidget.setSelectionBehavior(QAbstractItemView.SelectRows)
        if isinstance(columns, (list, tuple)):
            self.setSpec({'string_list': columns, 'comment': ''})
        else:
            self.keys = [] #No columns yet
        self.tablewidget.horizontalHeader().setStretchLastSection(True)
        self.tablewidget.horizontalHeader().sectionClicked.connect(self.tablewidget.clearSelection) #Allow to unselect the lines by clicking on the column name (useful to add a line at the end)

        self.label = QLabel(text, parent)
        self.button_add = QPushButton(QIcon(QPixmap(":/images/list-add.png")), "")
        self.button_remove = QPushButton(QIcon(QPixmap(":/images/list-remove.png")), "")
        self.button_add.clicked.connect(self.appendLine)
        self.button_remove.clicked.connect(self.removeLine)
        self.layout_button = QVBoxLayout();
        self.layout_button.addWidget(self.button_add)
        self.layout_button.addWidget(self.button_remove)

        self.layout_table = QHBoxLayout();
        #self.tablewidget.setSizePolicy(size_policy)
        self.layout_table.addWidget(self.tablewidget)
        self.layout_table.addLayout(self.layout_button)

        self.layout = QVBoxLayout(parent);

        self.layout.addWidget(self.label)
        self.layout.addLayout(self.layout_table)
        self.setLayout(self.layout)

        #Ensure that the table always expand to the maximum available space
        size_policy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        size_policy.setVerticalStretch(10)
        size_policy.setHorizontalStretch(10)
        self.setSizePolicy(size_policy)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号