当前位置: 首页>>代码示例>>Python>>正文


Python QTableView.setMinimumHeight方法代码示例

本文整理汇总了Python中PyQt5.QtWidgets.QTableView.setMinimumHeight方法的典型用法代码示例。如果您正苦于以下问题:Python QTableView.setMinimumHeight方法的具体用法?Python QTableView.setMinimumHeight怎么用?Python QTableView.setMinimumHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtWidgets.QTableView的用法示例。


在下文中一共展示了QTableView.setMinimumHeight方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: GroupWidget

# 需要导入模块: from PyQt5.QtWidgets import QTableView [as 别名]
# 或者: from PyQt5.QtWidgets.QTableView import setMinimumHeight [as 别名]
class GroupWidget(QWidget):

    _COLUMN_MAP = students.StudentColumnMap(
        columns=[
            students.StudentColumn.SEQUENCE_NUM,
            students.StudentColumn.ID,
            students.StudentColumn.NAME,
        ])

    def __init__(self, listing, student_tabs):
        super().__init__(student_tabs.tabs)
        self.listing = listing
        layout = QVBoxLayout()
        self.setLayout(layout)
        self.table = QTableView()
        self.table.setMinimumWidth(500)
        self.table.setMinimumHeight(300)
        layout.addWidget(self.table)
        self.model = StudentsTableModel(listing, GroupWidget._COLUMN_MAP, self)
        self.table.setModel(self.model)
        self.table.setSelectionBehavior(QTableView.SelectRows)
        layout.setAlignment(self.table, Qt.AlignHCenter)
        self._resize_table()

    def add_students(self, student_list):
        self.listing.add_students(student_list)
        self.listing_updated()

    def listing_updated(self):
        self.model.data_reset()
        self._resize_table()

    def _resize_table(self):
        self.table.resizeColumnToContents(0)
        self.table.horizontalHeader().setStretchLastSection(True)
开发者ID:jfisteus,项目名称:eyegrade,代码行数:37,代码来源:students.py

示例2: PreviewWidget

# 需要导入模块: from PyQt5.QtWidgets import QTableView [as 别名]
# 或者: from PyQt5.QtWidgets.QTableView import setMinimumHeight [as 别名]
class PreviewWidget(QWidget):
    def __init__(self, student_list, column_map, parent=None):
        super().__init__(parent)
        self.listing = students.GroupListing(None, student_list)
        self.column_map = column_map
        layout = QVBoxLayout()
        self.setLayout(layout)
        self.table = QTableView()
        self.table.setMinimumWidth(600)
        self.table.setMinimumHeight(300)
        layout.addWidget(self.table)
        self.model = StudentsTableModel(self.listing, column_map, self)
        self.table.setModel(self.model)
        self.table.setSelectionMode(QTableView.NoSelection)
        layout.setAlignment(self.table, Qt.AlignHCenter)
        self._resize_table()

    def swap_names(self):
        for s in self.listing.students:
            s.first_name, s.last_name = s.last_name, s.first_name
        self.model.data_reset()
        self._resize_table()

    def to_full_name(self, column):
        attr_name = students.ATTR_NAME[column]
        for s in self.listing.students:
            s.full_name = getattr(s, attr_name)
            s.first_name = ''
            s.last_name = ''
        self.column_map = self.column_map.to_full_name()
        self.model.data_reset(column_map=self.column_map)
        self._resize_table()

    def remove_duplicates(self):
        self.listing.remove_students([s for s in self.listing.students
                                      if s.is_duplicate])
        self.model.data_reset()

    def _resize_table(self):
        for i in range(len(self.column_map) - 1):
            self.table.resizeColumnToContents(i)
        self.table.horizontalHeader().setStretchLastSection(True)
开发者ID:jfisteus,项目名称:eyegrade,代码行数:44,代码来源:students.py

示例3: Universe

# 需要导入模块: from PyQt5.QtWidgets import QTableView [as 别名]
# 或者: from PyQt5.QtWidgets.QTableView import setMinimumHeight [as 别名]
class Universe(QGroupBox):
    """
    Handle Universe and display its attributes
    Only one is created and display universe_selected attributes
    """
    def __init__(self, parent):
        super(Universe, self).__init__()
        # make it available for the whole instance
        self.ola = parent.ola
        # intialize variable used in ola_connect method
        self.old = None
        self.universe_selected = None
        # Create universe attributes
        self.create_attributes()
        # Create the view to display values
        self.create_tableview()
        # Add the previous UI stuffs to a layout
        grid = self.create_layout()
        self.grid = grid
        self.setLayout(grid)
        parent.vbox.addWidget(self)
        self.parent = parent

    def create_attributes(self):
        """
        create attributes widget for the universe
        """
        self.id = QSpinBox()
        self.id.setReadOnly(True)
        self.id.setRange(0, 65536)
        self.name = QLineEdit()
        self.name.textEdited.connect(self.edit_name)
        self.name.setFixedWidth(200)
        self.merge_mode_label = QLabel('Merge Mode')
        self.merge_mode_htp_label = QLabel('HTP')
        self.merge_mode_htp = QRadioButton()
        self.merge_mode_ltp_label = QLabel('LTP')
        self.merge_mode_ltp = QRadioButton()
        self.merge_mode_ltp.toggled.connect(self.edit_merge_mode_ltp)
        self.merge_mode_htp.toggled.connect(self.edit_merge_mode_htp)

    def edit_name(self, name):
        if self.universe_selected:
            if self.ola.client.SetUniverseName(self.universe_selected.id, name):
                self.parent.universes_refresh()
            else:
                self.parent.status("name edit failed")
                if debug:
                    "edit universe name failed"

    def edit_merge_mode_htp(self, state):
        if state:
            if debug:
                print('switch universe to HTP merge mode')
            self.edit_merge_mode(1)

    def edit_merge_mode_ltp(self, state):
        if state:
            if debug:
                print('switch universe to LTP merge mode')
            self.edit_merge_mode(2)

    def edit_merge_mode(self, merge_mode):
        if self.universe_selected:
            if self.ola.client.SetUniverseMergeMode(self.universe_selected.id, merge_mode):
                self.parent.universes_refresh()
            else:
                self.parent.status("merge mode edit failed")
                if debug:
                    "edit universe merge mode failed"

    def create_tableview(self):
        """
        create the table view for DMX values
        """
        self.view = QTableView()
        self.view.setSelectionMode(QAbstractItemView.NoSelection)
        self.model = UniverseModel(self)
        self.view.setModel(self.model)
        # set up headers of the QTableView
        v_headers = QHeaderView(Qt.Vertical)
        self.view.setVerticalHeader(v_headers)
        h_headers = QHeaderView(Qt.Horizontal)
        self.view.setHorizontalHeader(h_headers)
        if debug :
            print('how many lines : ', v_headers.count())
            print('how many columns : ', h_headers.count())
        # set up rows and columns
        for col in range(self.model.columnCount()):
            self.view.setColumnWidth(col, 28)
        for row in range(self.model.rowCount()):
            self.view.setRowHeight(row, 20)
        self.view.setMinimumHeight(350)

    def create_layout(self):
        """
        create the layout for the universe display
        """
        grid = QGridLayout()
        grid.addWidget(self.id, 0, 0, 1, 1)
#.........这里部分代码省略.........
开发者ID:PixelStereo,项目名称:ola-pyqt-gui,代码行数:103,代码来源:universe.py


注:本文中的PyQt5.QtWidgets.QTableView.setMinimumHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。