本文整理汇总了Python中PyQt4.Qt.QTableView.setModel方法的典型用法代码示例。如果您正苦于以下问题:Python QTableView.setModel方法的具体用法?Python QTableView.setModel怎么用?Python QTableView.setModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QTableView
的用法示例。
在下文中一共展示了QTableView.setModel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PluginObject
# 需要导入模块: from PyQt4.Qt import QTableView [as 别名]
# 或者: from PyQt4.Qt.QTableView import setModel [as 别名]
#.........这里部分代码省略.........
if dlgEnterSegment.exec_():
segmentText = str(dlgEnterSegment.editSegment.text())
minLen = int(str(dlgEnterSegment.minSelector.currentText()))
maxLen = int(str(dlgEnterSegment.maxSelector.currentText()))
if len(segmentText)>0:
self.segDefList.append(UnknownSeg(segmentText, minLen, maxLen))
self.segDefTableModel.updateSegList(self.segDefList)
def addOrdering():
if len(self.segDefList) > 0:
dlgSpecifyOrdering = DlgSpecifyOrdering(main, main, len(self.segDefList))
if dlgSpecifyOrdering.exec_():
self.segOrdStrSet.add(str(dlgSpecifyOrdering.parseOrderingList()).strip('[]'))
self.updateOrderingListBox()
else:
QMessageBox.warning(self.main, tr('Not Ready'), tr("""
No segments have been entered. You must enter some segments before you can order them."""), QMessageBox.Ok)
self.main = main
self.segDefList = []
self.segOrdStrSet = set()
segmentHeader = QRichLabel(tr("""<b>Build segments for pass phrase search: </b>"""), doWrap=False)
self.knownButton = QPushButton("Add Known Segment")
self.unknownCaseButton = QPushButton("Add Unknown Case Segment")
self.unknownOrderButton = QPushButton("Add Unknown Order Segment")
self.main.connect(self.knownButton, SIGNAL('clicked()'), addKnownSegment)
self.main.connect(self.unknownCaseButton, SIGNAL('clicked()'), addUnknownCaseSegment)
self.main.connect(self.unknownOrderButton, SIGNAL('clicked()'), addUnknownOrderSegment)
topRow = makeHorizFrame([segmentHeader, self.knownButton, self.unknownCaseButton, self.unknownOrderButton, 'stretch'])
self.segDefTableModel = SegDefDisplayModel()
self.segDefTableView = QTableView()
self.segDefTableView.setModel(self.segDefTableModel)
self.segDefTableView.setSelectionBehavior(QTableView.SelectRows)
self.segDefTableView.setSelectionMode(QTableView.SingleSelection)
self.segDefTableView.verticalHeader().setDefaultSectionSize(20)
self.segDefTableView.verticalHeader().hide()
h = tightSizeNChar(self.segDefTableView, 1)[1]
self.segDefTableView.setMinimumHeight(2 * (1.3 * h))
self.segDefTableView.setMaximumHeight(10 * (1.3 * h))
initialColResize(self.segDefTableView, [.1, .2, .4, .1, .1, .1])
self.segDefTableView.customContextMenuRequested.connect(self.showSegContextMenu)
self.segDefTableView.setContextMenuPolicy(Qt.CustomContextMenu)
segmentOrderingsHeader = QRichLabel(tr("""<b>Specify orderings for pass phrase search: </b>"""), doWrap=False)
self.addOrderingButton = QPushButton("Add Ordering")
self.main.connect(self.addOrderingButton, SIGNAL('clicked()'), addOrdering)
orderingButtonPanel = makeHorizFrame([segmentOrderingsHeader, self.addOrderingButton, 'stretch'])
self.segOrdListBox = QListWidget()
self.segOrdListBox.customContextMenuRequested.connect(self.showOrdContextMenu)
self.segOrdListBox.setContextMenuPolicy(Qt.CustomContextMenu)
self.searchButton = QPushButton("Search")
self.main.connect(self.searchButton, SIGNAL('clicked()'), searchForPassphrase)
self.stopButton = QPushButton("Stop Searching")
self.stopButton.setEnabled(False)
self.main.connect(self.stopButton, SIGNAL('clicked()'), endSearch)
totalSearchLabel = QRichLabel(tr("""<b>Total Passphrase Tries To Search: </b>"""), doWrap=False)
示例2: MainWidget
# 需要导入模块: from PyQt4.Qt import QTableView [as 别名]
# 或者: from PyQt4.Qt.QTableView import setModel [as 别名]
class MainWidget(QWidget):
def __init__(self):
QWidget.__init__(self)
# define periodic table widget for element selection
self.periodicTableWidget = widgets.PeriodicTableDialog()
# initial molecule Zmatrix (can be empty)
# self.inp = []
self.inp = [['H'],
['O', 1, 0.9],
['O', 2, 1.4, 1, 105.],
['H', 3, 0.9, 2, 105., 1, 120.]]
self.atomList = []
self.highList = []
self.labelList = []
self.fast = False
# define & initialize ZMatModel that will contain Zmatrix data
self.ZMatModel = QStandardItemModel(len(self.inp), 7, self)
self.ZMatTable = QTableView(self)
self.ZMatTable.setModel(self.ZMatModel)
self.ZMatTable.setFixedWidth(325)
#self.ZMatTable.installEventFilter(self)
#self.ZMatModel.installEventFilter(self)
self.ZMatModel.setHorizontalHeaderLabels(['atom','','bond','','angle','','dihedral'])
for j, width in enumerate([40, 22, 65, 22, 65, 22, 65]):
self.ZMatTable.setColumnWidth(j, width)
# populate the ZMatModel
self.populateZMatModel()
#define Menu bar menus and their actions
self.menuBar = QMenuBar(self)
fileMenu = self.menuBar.addMenu('&File')
editMenu = self.menuBar.addMenu('&Edit')
viewMenu = self.menuBar.addMenu('&View')
measureMenu = self.menuBar.addMenu('&Measure')
helpMenu = self.menuBar.addMenu('&Help')
readZmatAction = QAction('&Read &ZMat', self)
readZmatAction.setShortcut('Ctrl+O')
readZmatAction.setStatusTip('Read Zmat from file')
readZmatAction.triggered.connect(self.readZmat)
fileMenu.addAction(readZmatAction)
readXYZAction = QAction('&Read &XYZ', self)
readXYZAction.setShortcut('Ctrl+Shift+O')
readXYZAction.setStatusTip('Read XYZ from file')
readXYZAction.triggered.connect(self.readXYZ)
fileMenu.addAction(readXYZAction)
readGaussianAction = QAction('&Read &Gaussian log', self)
readGaussianAction.setShortcut('Ctrl+G')
readGaussianAction.setStatusTip('Read Gaussian log file')
readGaussianAction.triggered.connect(self.readGaussian)
fileMenu.addAction(readGaussianAction)
writeZmatAction = QAction('&Write &ZMat', self)
writeZmatAction.setShortcut('Ctrl+S')
writeZmatAction.setStatusTip('Write Zmat to file')
writeZmatAction.triggered.connect(self.writeZmat)
fileMenu.addAction(writeZmatAction)
writeXYZAction = QAction('&Write &XYZ', self)
writeXYZAction.setShortcut('Ctrl+Shift+S')
writeXYZAction.setStatusTip('Write XYZ from file')
writeXYZAction.triggered.connect(self.writeXYZ)
fileMenu.addAction(writeXYZAction)
exitAction = QAction('&Exit', self)
exitAction.setShortcut('Ctrl+Q')
exitAction.setStatusTip('Exit application')
exitAction.triggered.connect(qApp.quit)
fileMenu.addAction(exitAction)
addRowAction = QAction('&Add &row', self)
addRowAction.setShortcut('Ctrl+R')
addRowAction.setStatusTip('Add row to ZMatrix')
addRowAction.triggered.connect(self.addRow)
editMenu.addAction(addRowAction)
deleteRowAction = QAction('&Delete &row', self)
deleteRowAction.setShortcut('Ctrl+Shift+R')
deleteRowAction.setStatusTip('Delete row from ZMatrix')
deleteRowAction.triggered.connect(self.deleteRow)
editMenu.addAction(deleteRowAction)
addAtomAction = QAction('&Add &atom', self)
addAtomAction.setShortcut('Ctrl+A')
addAtomAction.setStatusTip('Add atom to ZMatrix')
addAtomAction.triggered.connect(self.buildB)
editMenu.addAction(addAtomAction)
drawModeMenu = QMenu('Draw mode', self)
viewMenu.addMenu(drawModeMenu)
fastDrawAction = QAction('&Fast draw', self)
fastDrawAction.triggered.connect(self.fastDraw)
normalDrawAction = QAction('&Normal draw', self)
normalDrawAction.triggered.connect(self.normalDraw)
#.........这里部分代码省略.........
示例3: PluginObject
# 需要导入模块: from PyQt4.Qt import QTableView [as 别名]
# 或者: from PyQt4.Qt.QTableView import setModel [as 别名]
#.........这里部分代码省略.........
privKeyMap[scrAddr] = addrObj.binPrivKey32_Plain.copy()
signedTx = PyCreateAndSignTx(utxiList,
[],
privKeyMap, SIGHASH_NONE|SIGHASH_ANYONECANPAY )
print "-------------"
print binary_to_hex(signedTx.serialize())
# sock = socket.create_connection(('dust-b-gone.bitcoin.petertodd.org',80))
# sock.send(signedTx.serialize())
# sock.send(b'\n')
# sock.close()
except socket.error as err:
QMessageBox.critical(self.main, tr('Negative Value'), tr("""
Failed to connect to dust-b-gone server: %s""" % err.strerror), QMessageBox.Ok)
except NegativeValueError:
QMessageBox.critical(self.main, tr('Negative Value'), tr("""
You must enter a positive value of at least 0.0000 0001
and less than %s for the dust limit.""" % MAX_DUST_LIMIT_STR), QMessageBox.Ok)
except TooMuchPrecisionError:
QMessageBox.critical(self.main.main, tr('Too much precision'), tr("""
Bitcoins can only be specified down to 8 decimal places.
The smallest unit of a Groestlcoin is 0.0000 0001 GRS.
Please enter a dust limit of at least 0.0000 0001 and less than %s.""" % MAX_DUST_LIMIT_STR), QMessageBox.Ok)
finally:
for scraddr in privKeyMap:
privKeyMap[scraddr].destroy()
self.main = main
self.lblHeader = QRichLabel(tr("""<b>Dust Outputs for Wallet: None Selected</b>"""), doWrap=False)
self.beGoneDustButton = QPushButton("Remove Dust")
self.beGoneDustButton.setEnabled(False)
self.main.connect(self.beGoneDustButton, SIGNAL('clicked()'), sendDust)
topRow = makeHorizFrame([self.lblHeader,'stretch'])
secondRow = makeHorizFrame([self.beGoneDustButton, 'stretch'])
self.dustLimitLabel = QLabel("Max Dust Value (GRS): ")
self.dustLimitText = QLineEdit()
self.dustLimitText.setFont(GETFONT('Fixed'))
self.dustLimitText.setMinimumWidth(tightSizeNChar(self.dustLimitText, 6)[0])
self.dustLimitText.setMaximumWidth(tightSizeNChar(self.dustLimitText, 12)[0])
self.dustLimitText.setAlignment(Qt.AlignRight)
self.dustLimitText.setText(coin2str(DEFAULT_DUST_LIMIT))
self.main.connect(self.dustLimitText, SIGNAL('textChanged(QString)'), updateDustLimit)
limitPanel = makeHorizFrame([self.dustLimitLabel, self.dustLimitText, 'stretch'])
self.dustTableModel = DustDisplayModel()
self.dustTableView = QTableView()
self.dustTableView.setModel(self.dustTableModel)
self.dustTableView.setSelectionMode(QTableView.NoSelection)
self.dustTableView.verticalHeader().setDefaultSectionSize(20)
self.dustTableView.verticalHeader().hide()
h = tightSizeNChar(self.dustTableView, 1)[1]
self.dustTableView.setMinimumHeight(2 * (1.3 * h))
self.dustTableView.setMaximumHeight(10 * (1.3 * h))
initialColResize(self.dustTableView, [100, .7, .3])
self.dustTableView.setContextMenuPolicy(Qt.CustomContextMenu)
self.lblTxioInfo = QRichLabel('')
self.lblTxioInfo.setMinimumWidth(tightSizeNChar(self.lblTxioInfo, 30)[0])
self.main.connect(self.main.walletsView, SIGNAL('clicked(QModelIndex)'),
updateDustLimit)
self.dustBGoneFrame = makeVertFrame([topRow, secondRow, limitPanel, self.dustTableView, 'stretch'])
# Now set the scrollarea widget to the layout
self.tabToDisplay = QScrollArea()
self.tabToDisplay.setWidgetResizable(True)
self.tabToDisplay.setWidget(self.dustBGoneFrame)
def getSelectedWlt(self):
wlt = None
selectedWltList = self.main.walletsView.selectedIndexes()
if len(selectedWltList)>0:
row = selectedWltList[0].row()
wltID = str(self.main.walletsView.model().index(row, WLTVIEWCOLS.ID).data().toString())
wlt = self.main.walletMap[wltID]
return wlt
#############################################################################
def getTabToDisplay(self):
return self.tabToDisplay
def injectShutdownFunc(self):
try:
self.main.writeSetting('DustLedgerCols', saveTableView(self.dustTableView))
except:
LOGEXCEPT('Strange error during shutdown')