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


Python QtWidgets.QTableView类代码示例

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


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

示例1: __init__

 def __init__(self):
     super().__init__()
     self.setWindowTitle('Phone Book.')
     self.name = QLineEdit()
     self.number = QLineEdit()
     entry = QFormLayout()
     entry.addRow(QLabel('Name'), self.name)
     entry.addRow(QLabel('Number'), self.number)
     buttons = QHBoxLayout()
     button = QPushButton('&Add')
     button.clicked.connect(self._addEntry)
     buttons.addWidget(button)
     button = QPushButton('&Update')
     button.clicked.connect(self._updateEntry)
     buttons.addWidget(button)
     button = QPushButton('&Delete')
     button.clicked.connect(self._deleteEntry)
     buttons.addWidget(button)
     dataDisplay = QTableView()
     dataDisplay.setModel(PhoneDataModel())
     layout = QVBoxLayout()
     layout.addLayout(entry)
     layout.addLayout(buttons)
     layout.addWidget(dataDisplay)
     self.setLayout(layout)
     self.show()
开发者ID:stevengonsalvez,项目名称:python_training,代码行数:26,代码来源:phonebook_pyqt5.py

示例2: __init__

	def __init__(self, *args):
		# Invoke parent init
		QTableView.__init__(self, *args)
		
		# Get a reference to the window object
		self.win = get_app().window
		
		# Get Model data
		self.clip_properties_model = PropertiesModel(self)
		
		# Keep track of mouse press start position to determine when to start drag
		self.selected = []
		self.selected_item = None

		# Setup header columns
		self.setModel(self.clip_properties_model.model)
		self.setSelectionBehavior(QAbstractItemView.SelectRows)
		self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
		self.setWordWrap(True)

		# Get table header
		horizontal_header = self.horizontalHeader()
		horizontal_header.setSectionResizeMode(QHeaderView.Stretch)
		vertical_header = self.verticalHeader()
		vertical_header.setVisible(False)
		
		# Refresh view
		self.clip_properties_model.update_model()
		
		# Resize columns
		self.resizeColumnToContents(0)
		self.resizeColumnToContents(1)

		# Connect filter signals
		get_app().window.txtPropertyFilter.textChanged.connect(self.filter_changed)
开发者ID:kkfong,项目名称:openshot-qt,代码行数:35,代码来源:properties_tableview.py

示例3: __init__

 def __init__(self, parent):
     super(Table, self).__init__()
     self.parent = parent
     
     tablemodel = TableModel(self.parent.dictpar[self.parent.code]['vphi'], self)
     tableview = QTableView()
     tableview.setModel(tablemodel)
开发者ID:kharyuk,项目名称:astro,代码行数:7,代码来源:gui.py

示例4: UdpLogReceiver

class UdpLogReceiver(QWidget):
    """
        Log events generated by python logging objects.
    """
    def __init__(self, parent=None):
        super().__init__(parent)
        self._model = LogRecordModel()
        filter_model = QSortFilterProxyModel()
        filter_model.setSourceModel(self._model)
        filter_model.setFilterKeyColumn(3)

        self.msg_filter = QLineEdit()
        self.log_view = QTableView()
        self.log_view.setModel(filter_model)
        header = self.log_view.horizontalHeader()
        #header.setSectionResizeMode(header.Stretch)
        header.setStretchLastSection(True)
        self.status_label = QLabel()

        # Connect signals:
        self.msg_filter.textChanged.connect(filter_model.setFilterFixedString)
        # Make nice layout:
        layout = QVBoxLayout(self)
        layout.addWidget(self.msg_filter)
        layout.addWidget(self.log_view)
        layout.addWidget(self.status_label)

        # Attach udp server:
        self._udpServer = UdpHandler(self._model)
        self._model.stats_changed.connect(self.status_label.setText)
开发者ID:windelbouwman,项目名称:udplogviewer,代码行数:30,代码来源:udplogreceiver.py

示例5: __init__

    def __init__(self, tableName, parent=None):
        super(TableEditor, self).__init__(parent)

        self.model = QSqlTableModel(self)
        self.model.setTable(tableName)
        self.model.setEditStrategy(QSqlTableModel.OnManualSubmit)
        self.model.select()

        self.model.setHeaderData(0, Qt.Horizontal, "ID")
        self.model.setHeaderData(1, Qt.Horizontal, "First name")
        self.model.setHeaderData(2, Qt.Horizontal, "Last name")

        view = QTableView()
        view.setModel(self.model)

        submitButton = QPushButton("Submit")
        submitButton.setDefault(True)
        revertButton = QPushButton("&Revert")
        quitButton = QPushButton("Quit")

        buttonBox = QDialogButtonBox(Qt.Vertical)
        buttonBox.addButton(submitButton, QDialogButtonBox.ActionRole)
        buttonBox.addButton(revertButton, QDialogButtonBox.ActionRole)
        buttonBox.addButton(quitButton, QDialogButtonBox.RejectRole)

        submitButton.clicked.connect(self.submit)
        revertButton.clicked.connect(self.model.revertAll)
        quitButton.clicked.connect(self.close)

        mainLayout = QHBoxLayout()
        mainLayout.addWidget(view)
        mainLayout.addWidget(buttonBox)
        self.setLayout(mainLayout)

        self.setWindowTitle("Cached Table")
开发者ID:skyballoon,项目名称:PyQtTest,代码行数:35,代码来源:connGoTable.py

示例6: TestWidget

class TestWidget(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        vbox = QVBoxLayout(self)
        self.view = QTableView()
        self.model = Model(self.view)
        self.view.setModel(self.model)
        vbox.addWidget(self.view)
开发者ID:winsomexiao,项目名称:PyDemo,代码行数:8,代码来源:DBManager.py

示例7: __init__

    def __init__(self, parent):
        super().__init__(parent)
        self.logger = logging.getLogger(__name__)
        self.config = Configuration()
        self.filenames = []
        self.data = ""

        # left part of frame
        header_left = [_("Relative Path"), _("Name"), _("Size"), _("Date Modified")]
        self.file_model = FileTableModel(self, header_left, [])

        self.file_view = QTableView()
        self.file_view.setModel(self.file_model)
        self.file_view.setSortingEnabled(True)
        self.file_view.setAlternatingRowColors(True)
        self.file_view.setShowGrid(False)

        # adjustments
        self.file_view.verticalHeader().setDefaultSectionSize(22)
        # self.file_view.horizontalHeader().setDefaultSectionSize(self.file_view.width()/len(header))
        # self.file_view.horizontalHeader().setStretchLastSection(True)
        self.file_view.setSelectionMode(QAbstractItemView.SingleSelection)
        self.file_view.setSelectionBehavior(QAbstractItemView.SelectRows)

        self.file_view.doubleClicked.connect(self.file_view_doubleclicked)
        # self.file_view.clicked.connect(self.file_view_clicked)
        self.file_view.selectionModel().selectionChanged.connect(self.file_view_selection_changed)
        # self.file_view.setContextMenuPolicy(Qt.CustomContextMenu)
        # self.file_view.customContextMenuRequested.connect(self.file_view_context_menu_requested)

        # self.lb_nsfc = QLabel("")
        self.lb_path = QLabel("")
        self.lb_path.setFont(QFont("SansSerif", 10))

        self.pb_select = QPushButton(_("Select"))
        self.pb_select.clicked.connect(self.show_explorer)

        # right part of frame
        header_right = [_("Set Name"), _("Files"), _("New Files"), _("Update Files"), _("Unchanged Files")]
        self.overview_model = OverviewTableModel(self, header_right, [])
        self.overview = QTableView()
        self.overview.setModel(self.overview_model)
        self.overview.setAlternatingRowColors(True)
        self.overview.setShowGrid(False)

        self.overview.verticalHeader().setDefaultSectionSize(22)

        self.pb_publish = QPushButton(_("Publish"))
        self.pb_publish.clicked.connect(self.pb_publish_clicked)

        self.pb_zip = QPushButton(_("Create Zip"))
        self.pb_zip.clicked.connect(self.pb_zip_clicked)

        self.__init_ui__()
开发者ID:EHRI,项目名称:resyto,代码行数:54,代码来源:export_frame.py

示例8: __init__

    def __init__(self, model, parent=None):
        QTableView.__init__(self, parent)

        # Custom delegates.
        self._checkBoxDelegate = CheckBoxDelegateQt()
        self._floatEditDelegate = FloatEditDelegateQt()
        self._dateTimeEditDelegates = []  # Each of these can have different formats.
        self._comboBoxDelegates = []  # Each of these can have different choices.
        self._pushButtonDelegates = []  # Each of these can have different text.
        self._fileDialogDelegate = FileDialogDelegateQt()

        # Set the model.
        self.setModel(model)
开发者ID:marcel-goldschen-ohm,项目名称:ModelViewPyQt,代码行数:13,代码来源:ObjectListTableModelViewQt.py

示例9: setModel

 def setModel(self, model):
     QTableView.setModel(self, model)
     # The model needs to be set to set header stuff
     hheader = self.horizontalHeader()
     hheader.setHighlightSections(False)
     hheader.setStretchLastSection(False)
     hheader.resizeSection(0, 100)
     hheader.setSectionResizeMode(0, QHeaderView.Fixed)
     hheader.setSectionResizeMode(1, QHeaderView.Stretch)
     hheader.setSectionResizeMode(2, QHeaderView.Stretch)
     vheader = self.verticalHeader()
     vheader.setVisible(False)
     vheader.setDefaultSectionSize(18)
开发者ID:Beyond82,项目名称:dupeguru,代码行数:13,代码来源:details_table.py

示例10: draw_table

 def draw_table():
     tv = QTableView()
     tv.setMinimumSize(400, 400)
     tv.setShowGrid(False)
     vh = tv.verticalHeader()
     vh.setVisible(False)
     hh = tv.horizontalHeader()
     hh.setStretchLastSection(True)
     tv.setSortingEnabled(True)
     return tv
开发者ID:bohdanbobrowski,项目名称:keyword-counter,代码行数:10,代码来源:keyword_counter_window.py

示例11: MyWin

class MyWin(QWidget):
    def __init__(self, mydb):
        super(MyWin, self).__init__()
        main_lt = QVBoxLayout()
        self.view = QTableView()
        main_lt.addWidget(self.view)
        self.view.setWindowTitle("Table Model (View 1)")
        self.view.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.mydb = mydb

        button = QPushButton("Join")
        button.clicked.connect(self.merge)
        main_lt.addWidget(button)

        button = QPushButton("Exit")
        button.clicked.connect(lambda: exit())
        main_lt.addWidget(button)

        self.setLayout(main_lt)
        self.setWindowTitle('QT1')

    def set_model(self):
        self.view.setModel(self.mydb.get_model())

    def merge(self):
        ind_list = self.view.selectedIndexes()
        out = list(self.view.model().data(i) for i in ind_list)
        out = [out[i] for i in range(len(out)) if i % 2 == 0]
        if len(out) < 2:
            return
        self.mydb.merge(out)
        mb = QMessageBox()
        mb.setText('Merged %s' % str(out))
        mb.exec_()
        self.set_model()
开发者ID:greyfenrir,项目名称:qt.ex,代码行数:35,代码来源:master.py

示例12: __init__

    def __init__(self, *args):
        # Invoke parent init
        QTableView.__init__(self, *args)

        # Get a reference to the window object
        self.win = get_app().window

        # Get Model data
        self.clip_properties_model = PropertiesModel(self)
        self.transition_model = TransitionsModel(self)
        self.files_model = FilesModel(self)

        # Keep track of mouse press start position to determine when to start drag
        self.selected = []
        self.selected_label = None
        self.selected_item = None
        self.new_value = None
        self.original_data = None

        # Setup header columns
        self.setModel(self.clip_properties_model.model)
        self.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.setWordWrap(True)

        # Set delegate
        delegate = PropertyDelegate()
        self.setItemDelegateForColumn(1, delegate)
        self.previous_x = -1

        # Get table header
        horizontal_header = self.horizontalHeader()
        horizontal_header.setSectionResizeMode(QHeaderView.Stretch)
        vertical_header = self.verticalHeader()
        vertical_header.setVisible(False)

        # Refresh view
        self.clip_properties_model.update_model()
        self.transition_model.update_model()
        self.files_model.update_model()

        # Resize columns
        self.resizeColumnToContents(0)
        self.resizeColumnToContents(1)

        # Connect filter signals
        get_app().window.txtPropertyFilter.textChanged.connect(self.filter_changed)
        get_app().window.InsertKeyframe.connect(self.Insert_Action_Triggered)
        self.doubleClicked.connect(self.doubleClickedCB)
        self.loadProperties.connect(self.select_item)
开发者ID:OpenShot,项目名称:openshot-qt,代码行数:50,代码来源:properties_tableview.py

示例13: setModel

    def setModel(self, model):
        QTableView.setModel(self._table, model)
        self._table.setSelectionModel(model._selectionModel)
        
        if model.rowCount() > 0:
            self.setCurrentIndex(self.PAGE_LISTVIEW)
        else:
            self.setCurrentIndex(self.PAGE_EMPTY)

        model.rowsInserted.connect(self._onRowsChanged)
        model.rowsRemoved.connect(self._onRowsChanged)
        self.model=model
        
        self._setListViewLook()
开发者ID:DerThorsten,项目名称:ilastik,代码行数:14,代码来源:listView.py

示例14: keyPressEvent

 def keyPressEvent(self, event):
     self.firstrelease = True
     event_check = int(event.key())
     # event = event.key
     self.keylist.append(event_check)
     # print(self.keylist)
     Key_Control = 16777249
     Shift_Control = 16777248
     if event.key() == (Qt.Key_F1):  # It should show if there action not activated
         self.parent.showHelpMenu()
         return
     if Key_Control not in self.keylist:  # or  Qt.Key_Shift not in self.keylist:
         # print('Choice 1')
         QTableView.keyPressEvent(self, event)
         return
开发者ID:hovo1990,项目名称:GROM,代码行数:15,代码来源:tableView.py

示例15: _setupUi

 def _setupUi(self):
     self.setWindowTitle(tr("Problems!"))
     self.resize(413, 323)
     self.verticalLayout = QVBoxLayout(self)
     self.label = QLabel(self)
     msg = tr("There were problems processing some (or all) of the files. The cause of "
         "these problems are described in the table below. Those files were not "
         "removed from your results.")
     self.label.setText(msg)
     self.label.setWordWrap(True)
     self.verticalLayout.addWidget(self.label)
     self.tableView = QTableView(self)
     self.tableView.setEditTriggers(QAbstractItemView.NoEditTriggers)
     self.tableView.setSelectionMode(QAbstractItemView.SingleSelection)
     self.tableView.setSelectionBehavior(QAbstractItemView.SelectRows)
     self.tableView.setShowGrid(False)
     self.tableView.horizontalHeader().setStretchLastSection(True)
     self.tableView.verticalHeader().setDefaultSectionSize(18)
     self.tableView.verticalHeader().setHighlightSections(False)
     self.verticalLayout.addWidget(self.tableView)
     self.horizontalLayout = QHBoxLayout()
     self.revealButton = QPushButton(self)
     self.revealButton.setText(tr("Reveal Selected"))
     self.horizontalLayout.addWidget(self.revealButton)
     spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
     self.horizontalLayout.addItem(spacerItem)
     self.closeButton = QPushButton(self)
     self.closeButton.setText(tr("Close"))
     self.closeButton.setDefault(True)
     self.horizontalLayout.addWidget(self.closeButton)
     self.verticalLayout.addLayout(self.horizontalLayout)
开发者ID:Beyond82,项目名称:dupeguru,代码行数:31,代码来源:problem_dialog.py


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