本文整理汇总了Python中PyQt5.QtWidgets.QTableView.setWordWrap方法的典型用法代码示例。如果您正苦于以下问题:Python QTableView.setWordWrap方法的具体用法?Python QTableView.setWordWrap怎么用?Python QTableView.setWordWrap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QTableView
的用法示例。
在下文中一共展示了QTableView.setWordWrap方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ZoteroTableWidget
# 需要导入模块: from PyQt5.QtWidgets import QTableView [as 别名]
# 或者: from PyQt5.QtWidgets.QTableView import setWordWrap [as 别名]
class ZoteroTableWidget(QWidget):
def __init__(self, settings, directory, check_id_fct, annotations_path, parent=None):
super().__init__(parent)
# FIXME Delayed refactoring of check_id_fct and annotations_path.
# Variables section.
library_id = settings["libraryID"]
library_type = settings["libraryType"]
api_key = settings["apiKey"]
self._zotero = ZoteroWrap(library_id, library_type, api_key, directory)
# Widgets section.
model = ZoteroTableModel(self._zotero, check_id_fct, annotations_path)
model.load()
proxy_model = QSortFilterProxyModel()
proxy_model.setSourceModel(model)
proxy_model.setDynamicSortFilter(True)
proxy_model.setFilterCaseSensitivity(Qt.CaseInsensitive)
proxy_model.setFilterKeyColumn(-1) # NB: All columns.
self.view = QTableView(self)
self.view.setModel(proxy_model)
self.view.setCornerButtonEnabled(False)
self.view.setEditTriggers(QAbstractItemView.NoEditTriggers)
self.view.setSelectionBehavior(QAbstractItemView.SelectRows)
self.view.setSelectionMode(QAbstractItemView.SingleSelection)
# NB: Triggers a call to sortByColumn() which sorts by the first column.
self.view.setSortingEnabled(True)
self.view.setWordWrap(False)
self.view.verticalHeader().hide()
self.filter_edit = FilterEdit(self.view)
# NB: The thread does not begin executing until start() is called.
self.refresh_thread = ZoteroRefreshThread(model, self)
# Layouts section.
header_layout = QFormLayout()
header_layout.addRow("Filter:", self.filter_edit)
header_layout.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow)
utils.configure_form_layout(header_layout)
main_layout = QVBoxLayout()
main_layout.addLayout(header_layout)
main_layout.addWidget(self.view)
self.setLayout(main_layout)
# Signals section.
self.filter_edit.textChanged.connect(proxy_model.setFilterFixedString)
self.refresh_thread.started.connect(self.refresh_started)
self.refresh_thread.finished.connect(self.refresh_finished)
# def __del__(self):
# # FIXME Delayed refactoring. Not called when application is closed. Incorrect parent use?
# # NB: Exiting the program when another thread is still busy is a programming error.
# # NB: Call QThread::quit() if the thread has an event loop.
# print("DEBUG: ZoteroTableWidget.__del__()")
# # TODO Display an information dialog.
# self.refresh_thread.wait()
# print("DEBUG: ZoteroRefreshThread.wait() returned")
# Slots section.
@pyqtSlot()
def refresh_database(self):
"""Start the thread refreshing the Zotero data.
If the thread is already running, it is not restarted.
"""
self.refresh_thread.start()
@pyqtSlot()
def refresh_started(self):
"""Disable the Zotero widget when the thread refreshing its data runs.
Disable handling of keyboard/mouse events to ensure a thread-safe refresh.
"""
# TODO Display an information on top of the disabled widget.
self.setDisabled(True)
@pyqtSlot()
def refresh_finished(self):
"""Enable the Zotero widget when the thread refreshing its data finishes.
Reset the selection model of the view in case of new/deleted references.
Enable again the handling of keyboard/mouse events.
"""
self.view.selectionModel().reset()
self.setEnabled(True)
@pyqtSlot()
def add_reference(self):
"""Display the form for and handle the creation of a new reference."""
dialog = ZoteroReferenceDialog(self._zotero.reference_templates, self)
#.........这里部分代码省略.........
示例2: CharView
# 需要导入模块: from PyQt5.QtWidgets import QTableView [as 别名]
# 或者: from PyQt5.QtWidgets.QTableView import setWordWrap [as 别名]
#.........这里部分代码省略.........
# to the view so it can query the row under the mouse.
self.model = CharModel(self.chardata,self)
#Interpose a sort filter proxy between the view and the model.
self.proxy = CharFilter(self.chardata,self)
self.proxy.setSourceModel(self.model)
self.view.setModel(self.proxy)
# Hook up some signals.
# Connect the double-click signal to find_this.
self.view.doubleClicked.connect(self.find_this)
# Connect the CharsLoaded from the chardata object to our slot.
self.chardata.CharsLoaded.connect(self.chars_loaded)
# Connect the popup activated signal to our slot.
self.popup.activated.connect(self.new_filter)
# Connect the refresh button clicked signal to refresh below
self.refresh.clicked.connect(self.do_refresh)
# Connect the modelReset signal to our slot.
self.model.modelReset.connect(self.set_up_view)
# Slot to receive doubleClicked(index) from the table view, and
# convert that into a Find for that character.
def find_this(self, index):
repl = None
if index.column() == 3 :
# doubleclick was in the HTML entity column. Put the entity
# string from column 3 in the replace-1 field
repl = index.data(Qt.DisplayRole)
if index.column() != 0 :
# dblclick on some column other than 0. We need a reference to
# column 0, and we get it from the index.
index = index.sibling(index.row(),0)
what = index.data(Qt.DisplayRole) # get the character as a string
# Call for a find with respect case on, whole word and regex off
self.findpanel.find_this(what,case=True,word=False,regex=False,repl=repl)
# Slot to receive the CharsLoaded() signal from the chardata module
# (metadata has been loaded). Reset the table model.
def chars_loaded(self):
self.model.beginResetModel()
self.model.endResetModel()
# Slot to receive the activated(row) signal from the filter popup. Set
# the filter and reset the table model.
def new_filter(self,row):
self.model.beginResetModel()
self.proxy.set_filter(row)
self.model.endResetModel()
# Slot to receive the clicked() signal from the Refresh button.
# Warn the table model that things be changing, then call the
# database to do a new census, then finish the table reset.
def do_refresh(self):
self.model.beginResetModel()
self.chardata.refresh()
self.model.endResetModel()
# Slot to receive the modelReset() signal from the table model, emitted
# after the endResetModel() call. Set some features of our table view
# that we can't set until some data has been loaded.
def set_up_view(self):
self.view.resizeColumnsToContents()
self.view.horizontalHeader().setStretchLastSection(True)
self.view.resizeRowsToContents()
self.view.setSortingEnabled(True)
# Do all the fiddly UI stuff out of line.
def _uic(self):
mainLayout = QVBoxLayout()
self.setLayout(mainLayout)
topLayout = QHBoxLayout()
topLayout.setContentsMargins(0,0,0,0)
mainLayout.addLayout(topLayout,0)
# Lay out the refresh button and filter popup
self.refresh = QPushButton(
_TR('Button to reload all data in char panel',
'Refresh')
)
topLayout.addWidget(self.refresh,0)
topLayout.addStretch(1) # push filters to the right
self.popup = QComboBox()
# Set choices in popup, must match to the lambdas
# defined in CharFilter.set_filter()
self.popup.addItem(
_TR('char panel: show all characters',
'All')
)
self.popup.addItem(
_TR('char panel: show non-ascii characters',
'not 7-bit')
)
self.popup.addItem(
_TR('char panel: show non-latin-1',
'not Latin-1')
)
topLayout.addWidget(self.popup,0)
# Set up the table view, the actual visible table
self.view = QTableView()
self.view.setCornerButtonEnabled(False)
self.view.setWordWrap(False)
self.view.setAlternatingRowColors(True)
mainLayout.addWidget(self.view,1) # give it all the stretch
示例3: FnotePanel
# 需要导入模块: from PyQt5.QtWidgets import QTableView [as 别名]
# 或者: from PyQt5.QtWidgets.QTableView import setWordWrap [as 别名]
#.........这里部分代码省略.........
'A Footnote zone is defined by "/F" and "F/" lines.' )
utilities.warning_msg(emsg,expl,self)
return
# create a working cursor and start an undo macro on it.
worktc = self.edit_view.get_cursor()
worktc.beginEditBlock()
# Do the actual work inside a try-finally block so as to be sure
# that the Edit Block is ultimately closed.
try :
self.data_model.move_notes(worktc)
except Exception as whatever:
fnotview_logger.error(
'Unexpected error moving footnotes: {}'.format(whatever.args)
)
worktc.endEditBlock()
self.do_refresh()
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Set-up functions for initializing the UI elements.
# convenience functions to shorten the code of setting up 6 similar menus.
# make a combobox loaded with the stream names and set to a particular one.
def _make_cb(self, default, text) :
cb = QComboBox()
cb.addItems(stream_names)
cb.setCurrentIndex(default)
tt = _TR( 'Footnote panel popup menus',
'Choose the format to use when renumbering Note Keys such as:',
'will be followed by e.g. "[A]" or "[5]"' )
cb.setToolTip(tt+text)
return cb
# combine a combobox with a label in an hbox
def _make_pair(self, cb, caption):
hb = QHBoxLayout()
hb.addWidget( QLabel(caption) )
hb.addWidget(cb)
return hb
def _uic(self):
main_layout = QVBoxLayout()
self.setLayout(main_layout)
# make a horizontal layout of [Refresh Renumber Move]
top_box = QHBoxLayout()
# make the Refresh button with translated text
self.refresh_button = QPushButton(
_TR('Footnote panel Refresh button', 'Refresh') )
self.refresh_button.setToolTip(
_TR('Footnote panel Refresh button',
'Scan the book to find all footnotes and match them to their anchors' ) )
top_box.addWidget(self.refresh_button,0)
top_box.addStretch(1) # push next two buttons to the right
# Make the Renumber button
self.renumber_button = QPushButton(
_TR('Footnote panel Renumber button', 'Renumber') )
self.renumber_button.setToolTip(
_TR('Footnote panel Renumber button',
'Renumber all footnotes using the styles chosen in the menus below') )
top_box.addWidget(self.renumber_button,0)
# Make the Move button
self.move_button = QPushButton(
_TR('Footnote panel Move-to-zones button','Move to Zones') )
self.move_button.setToolTip(
_TR('Footnote panel Move button',
'Move all footnotes into zones marked /F ... F/' ) )
top_box.addWidget(self.move_button,0)
# Put that row of buttons at the top of the panel
main_layout.addLayout(top_box,0)
# Create the table, a very basic one, no sorting etc.
self.model = FnoteTableModel(self.data_model, self)
self.view = QTableView()
self.view.setModel(self.model)
self.view.setCornerButtonEnabled(False)
self.view.setWordWrap(False)
self.view.setAlternatingRowColors(False)
self.view.setSortingEnabled(False)
main_layout.addWidget(self.view,1) # Table gets all the stretch
# Create the six combo boxes. Initialize both IVX and ABC to
# the ABC stream and ivx and abc to the abc.
self.pick_IVX = self._make_cb(fnotdata.KeyClass_ABC, '[II]')
self.pick_ABC = self._make_cb(fnotdata.KeyClass_ABC, '[B]' )
self.pick_ivx = self._make_cb(fnotdata.KeyClass_abc, '[vi]')
self.pick_abc = self._make_cb(fnotdata.KeyClass_abc, '[b]' )
self.pick_123 = self._make_cb(fnotdata.KeyClass_123, '[2]' )
self.pick_sym = self._make_cb(fnotdata.KeyClass_sym, '[§]' )
# Create a 2x3 grid layout and put a label:combobox in each cell
grid = QGridLayout()
grid.addLayout( self._make_pair( self.pick_ABC, key_class_names[1] ), 0, 0)
grid.addLayout( self._make_pair( self.pick_IVX, key_class_names[0] ), 1, 0)
grid.addLayout( self._make_pair( self.pick_abc, key_class_names[3] ), 0, 1)
grid.addLayout( self._make_pair( self.pick_ivx, key_class_names[2] ), 1, 1)
grid.addLayout( self._make_pair( self.pick_123, key_class_names[4] ), 0, 2)
grid.addLayout( self._make_pair( self.pick_sym, key_class_names[5] ), 1, 2)
# Put the grid in an hbox with stretch on each side to center it
gridhb = QHBoxLayout()
gridhb.addStretch(1)
gridhb.addLayout(grid,0)
gridhb.addStretch(1)
# Add that row to the main layout
main_layout.addLayout(gridhb)
# End of _uic