本文整理汇总了Python中PyQt4.Qt.QTableWidgetItem.setFlags方法的典型用法代码示例。如果您正苦于以下问题:Python QTableWidgetItem.setFlags方法的具体用法?Python QTableWidgetItem.setFlags怎么用?Python QTableWidgetItem.setFlags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QTableWidgetItem
的用法示例。
在下文中一共展示了QTableWidgetItem.setFlags方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _addNewDescriptorTableRow
# 需要导入模块: from PyQt4.Qt import QTableWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTableWidgetItem import setFlags [as 别名]
def _addNewDescriptorTableRow(self, name, descriptor):
"""
Adds a new row to the descriptor table.
"""
row = self.descriptorsTable.rowCount()
self.descriptorsTable.insertRow(row)
item_widget = QTableWidgetItem(name)
item_widget.setFont(self.labelfont)
item_widget.setFlags(Qt.ItemIsSelectable |
Qt.ItemIsEnabled |
Qt.ItemIsEditable)
item_widget.setTextAlignment(Qt.AlignLeft)
self.descriptorsTable.setItem(row, 0, item_widget)
self.descriptorsTable.resizeColumnToContents(0)
s = self._makeProperAAString(descriptor)
item_widget = QTableWidgetItem(s)
item_widget.setFont(self.descriptorfont)
item_widget.setFlags(Qt.ItemIsSelectable |
Qt.ItemIsEnabled |
Qt.ItemIsEditable)
item_widget.setTextAlignment(Qt.AlignLeft)
self.descriptorsTable.setItem(row, 1, item_widget)
self.descriptorsTable.setColumnWidth(1,
self.descriptorsTable.width()-self.descriptorsTable.columnWidth(0)-20)
self.descriptorsTable.setRowHeight(row, 16)
示例2: populate_tbl_helper
# 需要导入模块: from PyQt4.Qt import QTableWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTableWidgetItem import setFlags [as 别名]
def populate_tbl_helper(hsgui, tbl, col_headers, col_editable, row_list, row2_data_tup ):
#tbl = main_skel.chip_TBL
hheader = tbl.horizontalHeader()
sort_col = hheader.sortIndicatorSection()
sort_ord = hheader.sortIndicatorOrder()
tbl.sortByColumn(0, Qt.AscendingOrder) # Basic Sorting
prevBlockSignals = tbl.blockSignals(True)
tbl.clear()
tbl.setColumnCount(len(col_headers))
tbl.setRowCount(len(row_list))
tbl.verticalHeader().hide()
tbl.setHorizontalHeaderLabels(col_headers)
tbl.setSelectionMode( QAbstractItemView.SingleSelection )
tbl.setSelectionBehavior( QAbstractItemView.SelectRows)
tbl.setSortingEnabled(False)
for row in iter(row_list):
data_tup = row2_data_tup[row]
for col, data in enumerate(data_tup):
item = QTableWidgetItem()
try:
int_data = int(data)
item.setData(Qt.DisplayRole, int_data)
except ValueError: # for strings
item.setText(str(data))
except TypeError: #for lists
item.setText(str(data))
item.setTextAlignment(Qt.AlignHCenter)
if col_editable[col]: item.setFlags(item.flags() | Qt.ItemIsEditable)
else: item.setFlags(item.flags() ^ Qt.ItemIsEditable)
tbl.setItem(row, col, item)
tbl.setSortingEnabled(True)
tbl.sortByColumn(sort_col,sort_ord) # Move back to old sorting
tbl.show()
tbl.blockSignals(prevBlockSignals)
示例3: _makeCheckItem
# 需要导入模块: from PyQt4.Qt import QTableWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTableWidgetItem import setFlags [as 别名]
def _makeCheckItem(self, name, group, attr):
item = QTableWidgetItem(name)
if group is self.model.defgroup:
item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
item.setCheckState(Qt.Checked if getattr(group.style, attr) else Qt.Unchecked)
else:
item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsTristate)
item.setCheckState(self.ShowAttrToCheckState[getattr(group.style, attr)])
return item
示例4: changeNew
# 需要导入模块: from PyQt4.Qt import QTableWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTableWidgetItem import setFlags [as 别名]
def changeNew(self, index):
filter = self._filters[self._keys[int(index)]]
ct = self.app.preferences.ui.configTable
ct.clear()
n = 0
ct.setRowCount(len(filter.config))
for key, value in filter.config.items():
twi = QTableWidgetItem(key)
twi.setFlags(Qt.ItemIsSelectable)
ct.setItem(n, 0, twi)
ct.setItem(n, 1, QTableWidgetItem(value))
n += 1
示例5: __init__
# 需要导入模块: from PyQt4.Qt import QTableWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTableWidgetItem import setFlags [as 别名]
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
# Dummy attributes to fool the Widget() option handler code. We handle
# everything in our *handler methods.
for i in range(1, 4):
x = 'sr%d_'%i
for y in ('search', 'replace'):
z = x + y
setattr(self, 'opt_'+z, z)
self.opt_search_replace = 'search_replace'
Widget.__init__(self, parent,
['search_replace',
'sr1_search', 'sr1_replace',
'sr2_search', 'sr2_replace',
'sr3_search', 'sr3_replace']
)
self.db, self.book_id = db, book_id
self.sr_search.set_msg(_('&Search Regular Expression'))
self.sr_search.set_book_id(book_id)
self.sr_search.set_db(db)
self.sr_search.doc_update.connect(self.update_doc)
proto = QTableWidgetItem()
proto.setFlags(Qt.ItemFlags(Qt.ItemIsSelectable + Qt.ItemIsEnabled))
self.search_replace.setItemPrototype(proto)
self.search_replace.setColumnCount(2)
self.search_replace.setColumnWidth(0, 320)
self.search_replace.setColumnWidth(1, 320)
self.search_replace.setHorizontalHeaderLabels([
_('Search Regular Expression'), _('Replacement Text')])
self.sr_add.clicked.connect(self.sr_add_clicked)
self.sr_change.clicked.connect(self.sr_change_clicked)
self.sr_remove.clicked.connect(self.sr_remove_clicked)
self.sr_load.clicked.connect(self.sr_load_clicked)
self.sr_save.clicked.connect(self.sr_save_clicked)
self.sr_up.clicked.connect(self.sr_up_clicked)
self.sr_down.clicked.connect(self.sr_down_clicked)
self.search_replace.currentCellChanged.connect(self.sr_currentCellChanged)
self.initialize_options(get_option, get_help, db, book_id)
示例6: __init__
# 需要导入模块: from PyQt4.Qt import QTableWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTableWidgetItem import setFlags [as 别名]
def __init__(self, parent, items):
QDialog.__init__(self, parent)
Ui_DeleteMatchingFromDeviceDialog.__init__(self)
self.setupUi(self)
self.explanation.setText('<p>'+_('All checked books will be '
'<b>permanently deleted</b> from your '
'device. Please verify the list.')+'</p>')
self.buttonBox.accepted.connect(self.accepted)
self.buttonBox.rejected.connect(self.rejected)
self.table.cellClicked.connect(self.cell_clicked)
self.table.setSelectionMode(QAbstractItemView.NoSelection)
self.table.setColumnCount(7)
self.table.setHorizontalHeaderLabels(
['', _('Location'), _('Title'), _('Author'),
_('Date'), _('Format'), _('Path')])
rows = 0
for card in items:
rows += len(items[card][1])
self.table.setRowCount(rows)
row = 0
for card in items:
(model,books) = items[card]
for (id,book) in books:
item = QTableWidgetItem()
item.setFlags(Qt.ItemIsUserCheckable|Qt.ItemIsEnabled)
item.setCheckState(Qt.Checked)
item.setData(Qt.UserRole, (model, id, book.path))
self.table.setItem(row, 0, item)
self.table.setItem(row, 1, tableItem(card))
self.table.setItem(row, 2, titleTableItem(book.title))
self.table.setItem(row, 3, authorTableItem(book))
self.table.setItem(row, 4, dateTableItem(book.datetime))
self.table.setItem(row, 5, centeredTableItem(book.path.rpartition('.')[2]))
self.table.setItem(row, 6, tableItem(book.path))
row += 1
self.table.setCurrentCell(0, 1)
self.table.resizeColumnsToContents()
self.table.setSortingEnabled(True)
self.table.sortByColumn(2, Qt.AscendingOrder)
self.table.setCurrentCell(0, 1)
示例7: _fillSequenceTable
# 需要导入模块: from PyQt4.Qt import QTableWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTableWidgetItem import setFlags [as 别名]
def _fillSequenceTable(self):
"""
"""
self.setComboBox = QComboBox()
for chunk in self.win.assy.molecules:
if chunk.isProteinChunk():
aa_list = chunk.protein.get_amino_acids()
aa_list_len = len(aa_list)
self.sequenceTable.setRowCount(aa_list_len)
for index in range(aa_list_len):
item_widget = QTableWidgetItem("")
item_widget.setFont(self.labelfont)
item_widget.setCheckState(Qt.Checked)
item_widget.setTextAlignment(Qt.AlignLeft)
item_widget.setSizeHint(QSize(20,12))
item_widget.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
self.sequenceTable.setItem(index, 0, item_widget)
item_widget = QTableWidgetItem(str(index+1))
item_widget.setFont(self.labelfont)
item_widget.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
item_widget.setTextAlignment(Qt.AlignCenter)
self.sequenceTable.setItem(index, 1, item_widget)
item_widget = QTableWidgetItem("Any")
item_widget.setFont(self.labelfont)
item_widget.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
item_widget.setTextAlignment(Qt.AlignCenter)
self.sequenceTable.setItem(index, 2, item_widget)
aa_string = self._get_mutation_descriptor(
self._get_aa_for_index(index))
item_widget = QTableWidgetItem(aa_string)
item_widget.setFont(self.descriptorfont)
self.sequenceTable.setItem(index, 3, item_widget)
self.sequenceTable.setRowHeight(index, 16)
self.win.connect(self.sequenceTable,
SIGNAL("cellClicked(int, int)"),
self._sequenceTableCellChanged)
self.sequenceTable.resizeColumnsToContents()
self.sequenceTable.setColumnWidth(0, 35)
self.sequenceTable.setColumnWidth(2, 80)
示例8: _fillSequenceTable
# 需要导入模块: from PyQt4.Qt import QTableWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTableWidgetItem import setFlags [as 别名]
def _fillSequenceTable(self):
"""
Fills in the sequence table.
"""
if not self.current_protein:
return
else:
currentProteinChunk = self.current_protein
self.editingItem = True
aa_list = currentProteinChunk.protein.get_amino_acids()
aa_list_len = len(aa_list)
self.sequenceTable.setRowCount(aa_list_len)
for index in range(aa_list_len):
# Selection checkbox column
item_widget = QTableWidgetItem("")
item_widget.setFont(self.labelfont)
item_widget.setCheckState(Qt.Checked)
item_widget.setTextAlignment(Qt.AlignLeft)
item_widget.setSizeHint(QSize(20,12))
item_widget.setFlags(Qt.ItemIsSelectable |
Qt.ItemIsEnabled |
Qt.ItemIsUserCheckable)
self.sequenceTable.setItem(index, 0, item_widget)
# Amino acid index column
item_widget = QTableWidgetItem(str(index+1))
item_widget.setFont(self.labelfont)
item_widget.setFlags(
Qt.ItemIsSelectable |
Qt.ItemIsEnabled)
item_widget.setTextAlignment(Qt.AlignCenter)
self.sequenceTable.setItem(index, 1, item_widget)
# Mutation descriptor name column
aa = self._get_aa_for_index(index)
item_widget = QTableWidgetItem(self._get_descriptor_name(aa))
item_widget.setFont(self.labelfont)
item_widget.setFlags(Qt.ItemIsSelectable |
Qt.ItemIsEnabled)
item_widget.setTextAlignment(Qt.AlignCenter)
self.sequenceTable.setItem(index, 2, item_widget)
# Backrub checkbox column
item_widget = QTableWidgetItem("")
item_widget.setFont(self.labelfont)
if aa.get_backrub_mode():
item_widget.setCheckState(Qt.Checked)
else:
item_widget.setCheckState(Qt.Unchecked)
item_widget.setTextAlignment(Qt.AlignLeft)
item_widget.setSizeHint(QSize(20,12))
item_widget.setFlags(Qt.ItemIsSelectable |
Qt.ItemIsEnabled |
Qt.ItemIsUserCheckable)
self.sequenceTable.setItem(index, 3, item_widget)
# Mutation descriptor column
aa_string = self._get_mutation_descriptor(aa)
item_widget = QTableWidgetItem(aa_string)
item_widget.setFont(self.descriptorfont)
self.sequenceTable.setItem(index, 4, item_widget)
self.sequenceTable.setRowHeight(index, 16)
self.editingItem = False
self.sequenceTable.resizeColumnsToContents()
self.sequenceTable.setColumnWidth(0, 35)
self.sequenceTable.setColumnWidth(2, 80)
self.sequenceTable.setColumnWidth(3, 35)
return
示例9: insertItems
# 需要导入模块: from PyQt4.Qt import QTableWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTableWidgetItem import setFlags [as 别名]
def insertItems(self, row, items):
"""
Insert the <items> specified items in this list widget.
The list widget shows item name string , as a QListwidgetItem.
This QListWidgetItem object defines a 'key' of a dictionary
(self._itemDictionary) and the 'value' of this key is the object
specified by the 'item' itself.
Example: self._itemDictionary['C6'] = instance of class Atom.
@param row: The row number for the item.
@type row: int
@param items: A list of objects. These objects are treated as values in
the self._itemDictionary
@type items: list
@param setAsDefault: Not used here. See PM_ListWidget.insertItems where
it is used.
@see: self.renameItemValue() for a comment about
self._suppress_itemChanged_signal
"""
#self.__init__ for a comment about this flag
self._suppress_itemChanged_signal = True
#Clear the previous contents of the self._itemDictionary
self._itemDictionary.clear()
#Clear the contents of this list widget, using QListWidget.clear()
#See U{<http://doc.trolltech.com/4.2/qlistwidget.html>} for details
self.clear()
seq = ['Node name', 'Number of bases']
self.setHorizontalHeaderLabels(seq)
self.setRowCount(len(items))
idx = 0
self.setSortingEnabled(False)
for item in items:
if hasattr(item.__class__, 'name'):
itemName = item.name
else:
itemName = str(item)
numberOfBasesString = ''
if isinstance(item, self.win.assy.DnaStrand):
numberOfBasesString = str(len(item.getAllAtoms()))
elif isinstance(item, self.win.assy.DnaSegment):
numberOfBasesString = str(item.getNumberOfBasePairs())
tableWidgetItem = QTableWidgetItem(itemName)
###When we support editing list widget items , uncomment out the
###following line . See also self.editItems -- Ninad 2008-01-16
##tableWidgetItem.setFlags( tableWidgetItem.flags()| Qt.ItemIsEditable)
if hasattr(item.__class__, 'iconPath'):
try:
tableWidgetItem.setIcon(geticon(item.iconPath))
except:
print_compact_traceback()
self._itemDictionary[tableWidgetItem] = item
self.setItem(idx, 0, tableWidgetItem)
tableWidgetItem_column_2 = QTableWidgetItem(numberOfBasesString)
tableWidgetItem_column_2.setFlags(Qt.ItemIsEnabled)
self.setItem(idx, 1, tableWidgetItem_column_2)
idx += 1
#Reset the flag that temporarily suppresses itemChange signal.
self._suppress_itemChanged_signal = False
self.setSortingEnabled(True)
示例10: _loadGroupBox1
# 需要导入模块: from PyQt4.Qt import QTableWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTableWidgetItem import setFlags [as 别名]
def _loadGroupBox1(self, pmGroupBox):
"""
Load widgets in group box.
"""
self.labelfont = QFont("Helvetica", 12)
self.descriptorfont = QFont("Courier New", 12)
self.headerdata = ['', 'ID', 'Set', 'Descriptor']
self.set_names = ["Any", "Same", "Locked", "Polar", "Apolar"]
self.rosetta_set_names = ["ALLAA", "NATRO", "NATAA", "POLAR", "APOLA"]
self.descriptor_list = ["GAVILMFWCSTYNQDEHKRP",
"____________________",
"____________________",
"________CSTYNQDEHKR_",
"GAVILMFW___________P"]
self.descriptorsTable = PM_TableWidget( pmGroupBox)
self.descriptorsTable.setFixedHeight(100)
self.descriptorsTable.setRowCount(len(self.set_names))
self.descriptorsTable.setColumnCount(2)
self.descriptorsTable.verticalHeader().setVisible(False)
self.descriptorsTable.horizontalHeader().setVisible(False)
for index in range(len(self.set_names)):
item_widget = QTableWidgetItem(self.set_names[index])
item_widget.setFont(self.labelfont)
item_widget.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)
item_widget.setTextAlignment(Qt.AlignCenter)
self.descriptorsTable.setItem(index, 0, item_widget)
item_widget = QTableWidgetItem(self.descriptor_list[index])
item_widget.setFont(self.descriptorfont)
item_widget.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)
item_widget.setTextAlignment(Qt.AlignCenter)
self.descriptorsTable.setItem(index, 1, item_widget)
self.descriptorsTable.setRowHeight(index, 16)
pass
self.descriptorsTable.resizeColumnsToContents()
self.applyDescriptorPushButton = PM_PushButton( pmGroupBox,
text = "Apply",
setAsDefault = True)
self.selectAllPushButton = PM_PushButton( pmGroupBox,
text = "All",
setAsDefault = True)
self.selectNonePushButton = PM_PushButton( pmGroupBox,
text = "None",
setAsDefault = True)
self.selectInvertPushButton = PM_PushButton( pmGroupBox,
text = "Invert",
setAsDefault = True)
self.win.connect(self.applyDescriptorPushButton,
SIGNAL("clicked()"),
self._applyDescriptor)
self.win.connect(self.selectAllPushButton,
SIGNAL("clicked()"),
self._selectAll)
self.win.connect(self.selectNonePushButton,
SIGNAL("clicked()"),
self._selectNone)
self.win.connect(self.selectInvertPushButton,
SIGNAL("clicked()"),
self._invertSelection)
buttonList = [('PM_PushButton', self.applyDescriptorPushButton, 0, 0),
('QSpacerItem', 5, 5, 1, 0),
('PM_PushButton', self.selectAllPushButton, 2, 0),
('PM_PushButton', self.selectNonePushButton, 3, 0),
('PM_PushButton', self.selectInvertPushButton, 4, 0)]
self.buttonGrid = PM_WidgetGrid( pmGroupBox,
widgetList = buttonList)
self.recenterViewCheckBox = \
PM_CheckBox( pmGroupBox,
text = "Re-center view",
setAsDefault = True,
state = Qt.Checked)
self.sequenceTable = PM_TableWidget( pmGroupBox)
#self.sequenceTable.setModel(self.tableModel)
self.sequenceTable.resizeColumnsToContents()
self.sequenceTable.verticalHeader().setVisible(False)
#self.sequenceTable.setRowCount(0)
self.sequenceTable.setColumnCount(4)
self.checkbox = QCheckBox()
#.........这里部分代码省略.........