本文整理汇总了Python中PyQt5.QtWidgets.QListView方法的典型用法代码示例。如果您正苦于以下问题:Python QtWidgets.QListView方法的具体用法?Python QtWidgets.QListView怎么用?Python QtWidgets.QListView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets
的用法示例。
在下文中一共展示了QtWidgets.QListView方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListView [as 别名]
def __init__(self, main_window, parent):
super(DragDropListView, self).__init__(parent)
self.main_window = main_window
self.setAcceptDrops(True)
self.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove)
self.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
self.setResizeMode(QtWidgets.QListView.Fixed)
self.setLayoutMode(QtWidgets.QListView.SinglePass)
self.setViewMode(QtWidgets.QListView.IconMode)
self.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
self.setProperty("showDropIndicator", False)
self.setProperty("isWrapping", True)
self.setFrameShape(QtWidgets.QFrame.NoFrame)
self.setUniformItemSizes(True)
self.setWordWrap(True)
self.setObjectName("listView")
示例2: accept
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListView [as 别名]
def accept(self):
"""Saves state on inputs; rough opposite of show()."""
for list_view in self.findChildren(QtWidgets.QListView):
for editor in list_view.findChildren(QtWidgets.QWidget, 'editor'):
list_view.commitData(editor) # if an editor is open, save it
self._addon.config.update({
widget.objectName(): (
widget.isChecked() if isinstance(widget, Checkbox)
else widget.atts_value if isinstance(widget, QtWidgets.QPushButton)
else widget.value() if isinstance(widget, QtWidgets.QSpinBox)
else widget.itemData(widget.currentIndex()) if isinstance(
widget, QtWidgets.QComboBox)
else [
i for i in widget.model().raw_data
if i['compiled'] and 'bad_replace' not in i
] if isinstance(widget, QtWidgets.QListView)
else widget.text()
)
for widget in self.findChildren(self._PROPERTY_WIDGETS)
if widget.objectName() in self._PROPERTY_KEYS
})
super(Configurator, self).accept()
示例3: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListView [as 别名]
def __init__(self, parent=None):
super(displayWidget, self).__init__(parent)
self.setMinimumWidth(426)
self.setMaximumWidth(426)
self.setMinimumHeight(404)
self.setDragEnabled(True)
self.setViewMode(QtWidgets.QListView.IconMode)
self.setIconSize(QtCore.QSize(24,24))
self.setGridSize(QtCore.QSize(25,25))
self.setMovement(QtWidgets.QListView.Static)
self.setAcceptDrops(False)
self.setDropIndicatorShown(True)
self.setResizeMode(QtWidgets.QListView.Adjust)
self.setUniformItemSizes(True)
self.setBackgroundRole(QtGui.QPalette.BrightText)
self.setMouseTracking(True)
self.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
self.setItemDelegate(self.TileItemDelegate())
示例4: setupUi
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListView [as 别名]
def setupUi(self, Dialog_selectfile):
Dialog_selectfile.setObjectName("Dialog_selectfile")
Dialog_selectfile.resize(400, 433)
self.buttonBox = QtWidgets.QDialogButtonBox(Dialog_selectfile)
self.buttonBox.setGeometry(QtCore.QRect(190, 390, 191, 32))
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
self.listView = QtWidgets.QListView(Dialog_selectfile)
self.listView.setGeometry(QtCore.QRect(10, 10, 371, 361))
self.listView.setObjectName("listView")
self.retranslateUi(Dialog_selectfile)
self.buttonBox.accepted.connect(Dialog_selectfile.accept)
self.buttonBox.rejected.connect(Dialog_selectfile.reject)
QtCore.QMetaObject.connectSlotsByName(Dialog_selectfile)
示例5: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListView [as 别名]
def __init__(self, parent):
self.parent = parent
self.parentTab = self.parent.parent
self.annotationListView = QtWidgets.QListView(self.parent)
self._translate = QtCore.QCoreApplication.translate
self.annotations_string = self._translate('SideDock', 'Annotations')
self.create_widgets()
示例6: create_widgets
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListView [as 别名]
def create_widgets(self):
self.annotationListView.setEditTriggers(QtWidgets.QListView.NoEditTriggers)
self.annotationListView.doubleClicked.connect(
self.parent.contentView.toggle_annotation_mode)
# Add widget to side dock
self.parent.sideDockTabWidget.addTab(
self.annotationListView, self.annotations_string)
示例7: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListView [as 别名]
def __init__(self):
QComboBox.__init__(self)
listView = QListView()
self.setView(listView)
return
示例8: populate_main_form
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListView [as 别名]
def populate_main_form(self):
list_view = QtWidgets.QListView()
list_view.setFixedWidth(115)
list_view.setModel(self.views_model)
select = QtCore.QItemSelectionModel.Select
list_view.selectionModel().select(self.views_model.createIndex(0, 0), select)
list_view.clicked.connect(self.view_clicked)
current_view = QtWidgets.QWidget()
view = self.view_about()
if not view:
view = QtWidgets.QBoxLayout()
current_view.setLayout(view)
self.splitter = QtWidgets.QSplitter(Qt.Horizontal)
self.splitter.addWidget(list_view)
self.splitter.addWidget(current_view)
self.splitter.setChildrenCollapsible(False)
self.splitter.show()
outer_layout = QtWidgets.QHBoxLayout()
outer_layout.addWidget(self.splitter)
self.parent.setLayout(outer_layout)
示例9: setupUi
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListView [as 别名]
def setupUi(self, IDAngrSavedsDialog):
IDAngrSavedsDialog.setObjectName("IDAngrSavedsDialog")
IDAngrSavedsDialog.resize(941, 569)
self.gridLayout = QtWidgets.QGridLayout(IDAngrSavedsDialog)
self.gridLayout.setObjectName("gridLayout")
self.splitter = QtWidgets.QSplitter(IDAngrSavedsDialog)
self.splitter.setOrientation(QtCore.Qt.Horizontal)
self.splitter.setObjectName("splitter")
self.selectorList = QtWidgets.QListView(self.splitter)
self.selectorList.setMaximumSize(QtCore.QSize(270, 16777215))
self.selectorList.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
self.selectorList.setObjectName("selectorList")
self.codeView = QtWidgets.QPlainTextEdit(self.splitter)
self.codeView.setReadOnly(True)
self.codeView.setObjectName("codeView")
self.gridLayout.addWidget(self.splitter, 0, 0, 1, 1)
self.buttonBox = QtWidgets.QDialogButtonBox(IDAngrSavedsDialog)
self.buttonBox.setMaximumSize(QtCore.QSize(16777215, 48))
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
self.gridLayout.addWidget(self.buttonBox, 1, 0, 1, 1)
self.retranslateUi(IDAngrSavedsDialog)
self.buttonBox.accepted.connect(IDAngrSavedsDialog.accept)
self.buttonBox.rejected.connect(IDAngrSavedsDialog.reject)
QtCore.QMetaObject.connectSlotsByName(IDAngrSavedsDialog)
示例10: _pull_presets
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListView [as 别名]
def _pull_presets(self):
"""Update current group's presets."""
name = self._current_group
if not name or name not in self._groups:
return
list_view = self.findChild(QtWidgets.QListView, 'presets')
for editor in list_view.findChildren(QtWidgets.QWidget, 'editor'):
list_view.commitData(editor) # if an editor is open, save it
self._groups[name]['presets'] = list_view.model().raw_data
示例11: setupUi
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListView [as 别名]
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(462, 431)
self.list_images = QtWidgets.QListView(MainWindow)
self.list_images.setGeometry(QtCore.QRect(10, 10, 180, 371))
self.list_images.setObjectName("list_images")
self.b_delete = QtWidgets.QPushButton(MainWindow)
self.b_delete.setGeometry(QtCore.QRect(10, 390, 180, 30))
self.b_delete.setObjectName("b_delete")
self.captured_image = QtWidgets.QLabel(MainWindow)
self.captured_image.setGeometry(QtCore.QRect(200, 10, 250, 100))
self.captured_image.setFrameShape(QtWidgets.QFrame.Box)
self.captured_image.setText("")
self.captured_image.setObjectName("captured_image")
self.b_save = QtWidgets.QPushButton(MainWindow)
self.b_save.setGeometry(QtCore.QRect(360, 390, 95, 30))
self.b_save.setObjectName("b_save")
self.groupBox = QtWidgets.QGroupBox(MainWindow)
self.groupBox.setGeometry(QtCore.QRect(200, 180, 141, 151))
self.groupBox.setObjectName("groupBox")
self.b_noIndicator = QtWidgets.QPushButton(self.groupBox)
self.b_noIndicator.setGeometry(QtCore.QRect(10, 30, 121, 30))
self.b_noIndicator.setObjectName("b_noIndicator")
self.b_leftIndicator = QtWidgets.QPushButton(self.groupBox)
self.b_leftIndicator.setGeometry(QtCore.QRect(10, 70, 121, 30))
self.b_leftIndicator.setObjectName("b_leftIndicator")
self.b_rightIndicator = QtWidgets.QPushButton(self.groupBox)
self.b_rightIndicator.setGeometry(QtCore.QRect(10, 110, 121, 30))
self.b_rightIndicator.setObjectName("b_rightIndicator")
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
示例12: show
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListView [as 别名]
def show(self, *args, **kwargs):
"""Restores state on inputs; rough opposite of the accept()."""
for widget, value in [
(widget, self._addon.config[widget.objectName()])
for widget in self.findChildren(self._PROPERTY_WIDGETS)
if widget.objectName() in self._PROPERTY_KEYS
]:
if isinstance(widget, Checkbox):
widget.setChecked(value)
widget.stateChanged.emit(value)
elif isinstance(widget, QtWidgets.QLineEdit):
widget.setText(value)
elif isinstance(widget, QtWidgets.QPushButton):
widget.atts_value = value
widget.setText(key_combo_desc(widget.atts_value))
elif isinstance(widget, QtWidgets.QComboBox):
widget.setCurrentIndex(max(widget.findData(value), 0))
elif isinstance(widget, QtWidgets.QSpinBox):
widget.setValue(value)
elif isinstance(widget, QtWidgets.QListView):
widget.setModel(value)
widget = self.findChild(QtWidgets.QPushButton, 'on_cache')
widget.atts_list = (
[filename for filename in os.listdir(self._addon.paths.cache)]
if os.path.isdir(self._addon.paths.cache) else []
)
if widget.atts_list:
widget.setEnabled(True)
widget.setText("Delete Files (%s)" %
locale("%d", len(widget.atts_list), grouping=True))
else:
widget.setEnabled(False)
widget.setText("Delete Files")
widget = self.findChild(QtWidgets.QPushButton, 'on_forget')
fail_count = self._addon.router.get_failure_count()
if fail_count:
widget.setEnabled(True)
widget.setText("Forget Failures (%s)" %
locale("%d", fail_count, grouping=True))
else:
widget.setEnabled(False)
widget.setText("Forget Failures")
super(Configurator, self).show(*args, **kwargs)
示例13: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListView [as 别名]
def __init__(self, object_type, parent=None):
"""
A dialog that opens to allow for the user to add a new reddit username to the username list. An instance of this
class is also used as a dialog to add subreddits, but two object names are overwritten. This dialog is basically
a standard input dialog, but with the addition of a third button that allows the user to add more than one name
without closing the dialog. Shortcut keys have also been added to facilitate ease of use
"""
QtWidgets.QDialog.__init__(self, parent=parent)
self.setupUi(self)
self.logger = logging.getLogger('DownloaderForReddit.%s' % __name__)
self.settings_manager = Injector.get_settings_manager()
self.object_type = object_type
self.layout_style = 'SINGLE'
self.object_name_list_view = QtWidgets.QListView()
self.object_name_list_view.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
self.object_name_list_model = AddRedditObjectListModel(self.object_type, self)
self.object_name_list_model.name_list_updated.connect(self.name_count_updated)
self.object_name_list_view.setModel(self.object_name_list_model)
self.name_count_label = QtWidgets.QLabel()
self.add_to_list_button = QtWidgets.QToolButton()
self.add_to_list_button.setText('+')
self.add_to_list_button.clicked.connect(self.add_name_to_list)
self.remove_from_list_button = QtWidgets.QToolButton()
self.remove_from_list_button.setText('-')
self.remove_from_list_button.clicked.connect(self.remove_name_from_list)
self.button_layout = QtWidgets.QHBoxLayout()
self.button_layout.addWidget(self.name_count_label)
self.button_layout.addWidget(self.add_to_list_button)
self.button_layout.addWidget(self.remove_from_list_button)
self.list_layout = QtWidgets.QVBoxLayout()
self.list_layout.addWidget(self.object_name_list_view)
self.list_layout.addLayout(self.button_layout)
self.name = None
self.init_download_on_add_checkbox()
self.download_on_add_checkbox.toggled.connect(self.toggle_download_on_add_checkbox)
self.ok_cancel_button_box.accepted.connect(self.accept)
self.ok_cancel_button_box.rejected.connect(self.close)
self.object_name_line_edit.textChanged.connect(self.check_line_edit_text)
self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.customContextMenuRequested.connect(lambda: self.show_context_menu(False))
self.object_name_line_edit.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.object_name_line_edit.customContextMenuRequested.connect(lambda: self.show_context_menu(True))
示例14: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListView [as 别名]
def __init__(self):
"""MainWindow constructor.
This widget will be our main window.
We'll define all the UI components in here.
"""
super().__init__()
# Main UI code goes here
self.setLayout(qtw.QVBoxLayout())
data = [
'Hamburger', 'Cheeseburger',
'Chicken Nuggets', 'Hot Dog', 'Fish Sandwich'
]
listwidget = qtw.QListWidget()
listwidget.addItems(data)
combobox = qtw.QComboBox()
combobox.addItems(data)
self.layout().addWidget(listwidget)
self.layout().addWidget(combobox)
# make the list widget editable
for i in range(listwidget.count()):
item = listwidget.item(i)
item.setFlags(item.flags() | qtc.Qt.ItemIsEditable)
# The same, but with a model
model = qtc.QStringListModel(data)
listview = qtw.QListView()
listview.setModel(model)
model_combobox = qtw.QComboBox()
model_combobox.setModel(model)
self.layout().addWidget(listview)
self.layout().addWidget(model_combobox)
# End main UI code
self.show()
示例15: setupUi
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListView [as 别名]
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(486, 313)
MainWindow.setStyleSheet("QListView::item:alternate {\n"
" \n"
" background-color: rgb(85, 255, 255);\n"
"}")
MainWindow.setTabShape(QtWidgets.QTabWidget.Rounded)
MainWindow.setDockOptions(QtWidgets.QMainWindow.AllowTabbedDocks|QtWidgets.QMainWindow.AnimatedDocks)
self.centralWidget = QtWidgets.QWidget(MainWindow)
self.centralWidget.setObjectName("centralWidget")
self.verticalLayout = QtWidgets.QGridLayout(self.centralWidget)
self.verticalLayout.setObjectName("verticalLayout")
self.l3 = QtWidgets.QLineEdit(self.centralWidget)
self.l3.setObjectName("l3")
self.verticalLayout.addWidget(self.l3, 6, 0, 1, 1)
self.l1 = QtWidgets.QLineEdit(self.centralWidget)
self.l1.setObjectName("l1")
self.verticalLayout.addWidget(self.l1, 4, 0, 1, 1)
self.l2 = QtWidgets.QLineEdit(self.centralWidget)
self.l2.setObjectName("l2")
self.verticalLayout.addWidget(self.l2, 5, 0, 1, 1)
self.pre_btn = QtWidgets.QPushButton(self.centralWidget)
self.pre_btn.setObjectName("pre_btn")
self.verticalLayout.addWidget(self.pre_btn, 1, 0, 1, 1)
self.tableView = QtWidgets.QTableView(self.centralWidget)
self.tableView.setObjectName("tableView")
self.verticalLayout.addWidget(self.tableView, 0, 0, 1, 1)
self.next_btn = QtWidgets.QPushButton(self.centralWidget)
self.next_btn.setObjectName("next_btn")
self.verticalLayout.addWidget(self.next_btn, 2, 0, 1, 1)
self.listView = QtWidgets.QListView(self.centralWidget)
self.listView.setObjectName("listView")
self.verticalLayout.addWidget(self.listView, 0, 1, 1, 1)
self.sub_btn = QtWidgets.QPushButton(self.centralWidget)
self.sub_btn.setObjectName("sub_btn")
self.verticalLayout.addWidget(self.sub_btn, 3, 0, 1, 1)
self.l4 = QtWidgets.QLineEdit(self.centralWidget)
self.l4.setObjectName("l4")
self.verticalLayout.addWidget(self.l4, 7, 0, 1, 1)
self.l5 = QtWidgets.QLineEdit(self.centralWidget)
self.l5.setObjectName("l5")
self.verticalLayout.addWidget(self.l5, 8, 0, 1, 1)
MainWindow.setCentralWidget(self.centralWidget)
self.saveaction = QtWidgets.QAction(MainWindow)
self.saveaction.setObjectName("saveaction")
self.action12 = QtWidgets.QAction(MainWindow)
self.action12.setObjectName("action12")
self.actionas = QtWidgets.QAction(MainWindow)
self.actionas.setObjectName("actionas")
self.actiondz = QtWidgets.QAction(MainWindow)
self.actiondz.setObjectName("actiondz")
self.actiongc = QtWidgets.QAction(MainWindow)
self.actiongc.setObjectName("actiongc")
self.actiondb = QtWidgets.QAction(MainWindow)
self.actiondb.setObjectName("actiondb")
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)