本文整理汇总了Python中PyQt5.QtWidgets.QListWidget方法的典型用法代码示例。如果您正苦于以下问题:Python QtWidgets.QListWidget方法的具体用法?Python QtWidgets.QListWidget怎么用?Python QtWidgets.QListWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets
的用法示例。
在下文中一共展示了QtWidgets.QListWidget方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListWidget [as 别名]
def __init__(self, parent=None):
super(ArchiveWindow, self).__init__(parent)
loadUi('UI/Archive.ui', self)
self.cancel.clicked.connect(self.close)
self.log_tabwidget.clear()
self.violation_list = QListWidget(self)
self.log_tabwidget.addTab(self.violation_list, "Violations")
self.violation_list.clear()
rows = Database.get_instance().get_violations_from_cam(None, cleared=True)
for row in rows:
listWidget = ViolationItem()
listWidget.setData(row)
listWidgetItem = QtWidgets.QListWidgetItem(self.violation_list)
listWidgetItem.setSizeHint(listWidget.sizeHint())
self.violation_list.addItem(listWidgetItem)
self.violation_list.setItemWidget(listWidgetItem, listWidget)
示例2: setupUi
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListWidget [as 别名]
def setupUi(self, QHangupsConversationsList):
QHangupsConversationsList.setObjectName("QHangupsConversationsList")
QHangupsConversationsList.resize(250, 500)
self.centralwidget = QtWidgets.QWidget(QHangupsConversationsList)
self.centralwidget.setObjectName("centralwidget")
self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)
self.verticalLayout.setObjectName("verticalLayout")
self.conversationsListWidget = QtWidgets.QListWidget(self.centralwidget)
self.conversationsListWidget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.conversationsListWidget.setObjectName("conversationsListWidget")
self.verticalLayout.addWidget(self.conversationsListWidget)
QHangupsConversationsList.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(QHangupsConversationsList)
self.menubar.setGeometry(QtCore.QRect(0, 0, 250, 27))
self.menubar.setObjectName("menubar")
QHangupsConversationsList.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(QHangupsConversationsList)
self.statusbar.setObjectName("statusbar")
QHangupsConversationsList.setStatusBar(self.statusbar)
self.retranslateUi(QHangupsConversationsList)
QtCore.QMetaObject.connectSlotsByName(QHangupsConversationsList)
示例3: equationsLayout
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListWidget [as 别名]
def equationsLayout(self):
self.myQListWidget = QtWidgets.QListWidget(self)
for index, name in self.equations:
myQCustomQWidget = QCustomQWidget()
myQCustomQWidget.setTextUp(index)
myQCustomQWidget.setTextDown(name)
myQListWidgetItem = QtWidgets.QListWidgetItem(self.myQListWidget)
myQListWidgetItem.setSizeHint(myQCustomQWidget.sizeHint())
self.myQListWidget.addItem(myQListWidgetItem)
self.myQListWidget.setItemWidget(
myQListWidgetItem, myQCustomQWidget)
self.myQListWidget.resize(400, 300)
self.equationListVbox.addWidget(self.myQListWidget)
self.myQListWidget.itemClicked.connect(self.Clicked)
self.clearButton = QtWidgets.QPushButton('Clear equations')
self.clearButton.clicked.connect(self.clearHistory)
self.clearButton.setStatusTip("Clear history")
self.equationListVbox.addWidget(self.clearButton)
return self.equationListVbox
示例4: library
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListWidget [as 别名]
def library(self):
self.list_library = QtWidgets.QListWidget()
self.list_library.setObjectName("list_library")
self.add_library_btn = QPushButtonExtra()
self.add_library_btn.setObjectName('add_library_btn')
self.add_library_btn.setText(" Add Folder ")
self.remove_library_btn = QPushButtonExtra()
self.remove_library_btn.setObjectName('remove_library_btn')
self.remove_library_btn.setText(' Remove Folder ')
self.add_library_btn.setMinimumHeight(32)
self.remove_library_btn.setMinimumHeight(32)
self.gl5.addWidget(self.list_library, 0, 0, 1, 2)
self.gl5.addWidget(self.add_library_btn, 1, 0, 1, 1)
self.gl5.addWidget(self.remove_library_btn, 1, 1, 1, 1)
if os.path.exists(self.library_file_name):
lines = open_files(self.library_file_name, True)
self.list_library.clear()
for i in lines:
i = i.strip()
self.list_library.addItem(i)
self.add_library_btn.clicked_connect(self.add_folder_to_library)
self.remove_library_btn.clicked_connect(self.remove_folder_from_library)
示例5: received_titles
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListWidget [as 别名]
def received_titles(self, client, channel, action, content):
"""
Received all available scenario titles as a list together with the file names
which act as unique identifiers. The list is sorted by title.
"""
# immediately close the channel, we do not want to get this content twice
client.remove_channel(channel)
# unpack content
scenario_titles, self.scenario_files = zip(*content)
# create list widget
self.list = QtWidgets.QListWidget()
self.list.itemSelectionChanged.connect(self.selection_changed)
self.list.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection)
self.list.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.list.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.list.addItems(scenario_titles)
# set height size fixed to content
self.list.setFixedHeight(self.list.sizeHintForRow(0) * self.list.count() + 2 * self.list.frameWidth())
self.layout.addWidget(self.list)
示例6: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListWidget [as 别名]
def __init__(self, parent=None):
super(UI_unitConverter, self).__init__(parent)
self.setWindowTitle(
QtWidgets.QApplication.translate("pychemqt", "Units converter"))
self.verticalLayout = QtWidgets.QVBoxLayout(self)
self.lista = QtWidgets.QListWidget()
self.lista.itemDoubleClicked.connect(self.showChildWindow)
self.verticalLayout.addWidget(self.lista)
self.buttonBox = QtWidgets.QDialogButtonBox(
QtWidgets.QDialogButtonBox.Close)
self.buttonBox.rejected.connect(self.reject)
self.verticalLayout.addWidget(self.buttonBox)
for unidad in _all:
self.lista.addItem(unidad.__title__)
self.lista.setCurrentRow(-1)
logging.info(QtWidgets.QApplication.translate(
"pychemqt", "Starting unit converte tool"))
示例7: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListWidget [as 别名]
def __init__(self, label, parent=None):
super().__init__(parent)
button = QtWidgets.QToolButton()
button.setText('...')
button.clicked.connect(self.add_folder)
self.lineEdit = QtWidgets.QToolButton()
self.lineEdit.setText(label)
folder_getter_layout = QtWidgets.QHBoxLayout()
folder_getter_layout.addWidget(self.lineEdit, 85)
folder_getter_layout.addWidget(button, 15)
self.list_widget = QtWidgets.QListWidget()
self.list_widget.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
main_layout = QtWidgets.QVBoxLayout()
main_layout.addLayout(folder_getter_layout)
main_layout.addWidget(self.list_widget)
self.setLayout(main_layout)
示例8: on_save_log
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListWidget [as 别名]
def on_save_log(self):
file_name, _ = QFileDialog.getSaveFileName( # second return value contains the used file type filter.
self.window(),
"Save log file",
"",
"" # TODO: File type filter. Maybe "*.log"?
)
del _ # We are only interested in the selected file name
if file_name:
list_widget = self.listWidget # type: QListWidget
item_texts = (list_widget.item(row).text() for row in range(list_widget.count()))
log_text = "\n".join(item_texts) + "\n"
try:
with open(file_name, "w") as log_file:
log_file.write(log_text)
except IOError:
logger.exception("Error saving log file")
else:
self.on_clear_log() # Error log saved, so clear the previously saved entries
示例9: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListWidget [as 别名]
def __init__(self, parent=None):
super(ArchiveWindow, self).__init__(parent)
loadUi('UI/Archive.ui', self)
self.cancel.clicked.connect(self.close)
self.log_tabwidget.clear()
self.violation_list = QListWidget(self)
self.log_tabwidget.addTab(self.violation_list, "Violations")
self.violation_list.clear()
rows = Database.getInstance().getViolationsFromCam(None, cleared=True)
for row in rows:
listWidget = ViolationItem()
listWidget.setData(row)
listWidgetItem = QtWidgets.QListWidgetItem(self.violation_list)
listWidgetItem.setSizeHint(listWidget.sizeHint())
self.violation_list.addItem(listWidgetItem)
self.violation_list.setItemWidget(listWidgetItem, listWidget)
示例10: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListWidget [as 别名]
def __init__(self, tables, current=0, parent=None):
super(PaletteSelector, self).__init__(parent)
self.pnames, self.pcolors = tables
self.palette = current
self.setWindowTitle("Colour palette chooser")
layout = QtWidgets.QVBoxLayout(self)
self.showpalette = QtWidgets.QLabel()
self.update(self.palette)
wid = QtWidgets.QLabel("Select colour palette:")
layout.addWidget(self.showpalette)
layout.addWidget(wid)
self.list = QtWidgets.QListWidget()
self.list.addItems(self.pnames)
layout.addWidget(self.list)
self.buttons = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel, QtCore.Qt.Horizontal, self)
layout.addWidget(self.buttons)
self.buttons.accepted.connect(self.accept)
self.buttons.rejected.connect(self.reject)
self.list.itemClicked.connect(self.item_click)
示例11: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListWidget [as 别名]
def __init__(self):
super().__init__()
self.isPoppable = True
self.canGoHome = True
self.wgt.setMinimumWidth(400)
self.wgt.setMinimumHeight(225)
self.liveTickets = {}
# Network statistics
lbl = Q.makeLabel("Live Tickets", 18)
self.layout.addWidget(lbl, 0, Q.ALIGN_LEFT)
# List of live tickets. Click to open dcrdata in browser.
wgt = self.ticketsWgt = QtWidgets.QListWidget()
wgt.itemClicked.connect(self.onTicketItemClicked)
self.layout.addWidget(wgt, 0, Q.ALIGN_LEFT)
示例12: setupUi
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListWidget [as 别名]
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(241, 367)
self.gridLayout = QtWidgets.QGridLayout(Form)
self.gridLayout.setSpacing(0)
self.gridLayout.setObjectName("gridLayout")
self.label = QtWidgets.QLabel(Form)
self.label.setObjectName("label")
self.gridLayout.addWidget(self.label, 0, 0, 1, 3)
self.itemTree = QtWidgets.QTreeWidget(Form)
self.itemTree.setObjectName("itemTree")
self.itemTree.headerItem().setText(0, "1")
self.itemTree.header().setVisible(False)
self.gridLayout.addWidget(self.itemTree, 1, 0, 1, 3)
self.label_2 = QtWidgets.QLabel(Form)
self.label_2.setObjectName("label_2")
self.gridLayout.addWidget(self.label_2, 2, 0, 1, 3)
self.formatList = QtWidgets.QListWidget(Form)
self.formatList.setObjectName("formatList")
self.gridLayout.addWidget(self.formatList, 3, 0, 1, 3)
self.exportBtn = QtWidgets.QPushButton(Form)
self.exportBtn.setObjectName("exportBtn")
self.gridLayout.addWidget(self.exportBtn, 6, 1, 1, 1)
self.closeBtn = QtWidgets.QPushButton(Form)
self.closeBtn.setObjectName("closeBtn")
self.gridLayout.addWidget(self.closeBtn, 6, 2, 1, 1)
self.paramTree = ParameterTree(Form)
self.paramTree.setObjectName("paramTree")
self.paramTree.headerItem().setText(0, "1")
self.paramTree.header().setVisible(False)
self.gridLayout.addWidget(self.paramTree, 5, 0, 1, 3)
self.label_3 = QtWidgets.QLabel(Form)
self.label_3.setObjectName("label_3")
self.gridLayout.addWidget(self.label_3, 4, 0, 1, 3)
self.copyBtn = QtWidgets.QPushButton(Form)
self.copyBtn.setObjectName("copyBtn")
self.gridLayout.addWidget(self.copyBtn, 6, 0, 1, 1)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
示例13: clearHistory
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListWidget [as 别名]
def clearHistory(self):
for i in reversed(range(self.equationListVbox.count())):
self.equationListVbox.itemAt(i).widget().setParent(None)
self.equations = [('No equations stored', '')]
file = open('local/eqn-list.vis', 'r+')
file.truncate()
self.myQListWidget = QtWidgets.QListWidget(self)
i = 0
for index, name in self.equations:
if i != 0:
file.write("\n")
file.write(name)
myQCustomQWidget = QCustomQWidget()
myQCustomQWidget.setTextUp(index)
myQCustomQWidget.setTextDown(name)
myQListWidgetItem = QtWidgets.QListWidgetItem(self.myQListWidget)
myQListWidgetItem.setSizeHint(myQCustomQWidget.sizeHint())
self.myQListWidget.addItem(myQListWidgetItem)
self.myQListWidget.setItemWidget(
myQListWidgetItem, myQCustomQWidget)
i += 1
file.close()
self.myQListWidget.resize(400, 300)
self.myQListWidget.itemClicked.connect(self.Clicked)
self.equationListVbox.addWidget(self.myQListWidget)
self.clearButton = QtWidgets.QPushButton('Clear equations')
self.clearButton.clicked.connect(self.clearHistory)
self.equationListVbox.addWidget(self.clearButton)
return self.equationListVbox
示例14: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListWidget [as 别名]
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
layout = QtWidgets.QHBoxLayout(self)
self.client_list_widget = QtWidgets.QListWidget()
# list.itemSelectionChanged.connect(self.selection_changed)
# list.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
self.client_list_widget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.client_list_widget.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
self.client_list_widget.setFixedWidth(200)
layout.addWidget(qt.wrap_in_groupbox(self.client_list_widget, 'Players'))
self.chat_log_text_edit = QtWidgets.QTextEdit()
self.chat_log_text_edit.setEnabled(False)
chat_log_group = qt.wrap_in_groupbox(self.chat_log_text_edit, 'Chat log')
self.chat_input_edit = QtWidgets.QLineEdit()
self.chat_input_edit.returnPressed.connect(self.send_chat_message)
chat_input_group = qt.wrap_in_groupbox(self.chat_input_edit, 'Chat input')
layout.addLayout(qt.wrap_in_boxlayout((chat_log_group, chat_input_group), horizontal=False, add_stretch=False),
stretch=1)
# connection to server
# chat messages
local_network_client.connect_to_channel(constants.C.CHAT, self.receive_chat_messages)
local_network_client.send(constants.C.CHAT, constants.M.CHAT_SUBSCRIBE)
# LOBBY
local_network_client.connect_to_channel(constants.C.LOBBY, self.receive_lobby_messages)
self.request_updated_client_list()
# set timer for connected client updates
self.timer = QtCore.QTimer()
self.timer.timeout.connect(self.request_updated_client_list)
self.timer.setInterval(5000)
self.timer.start()
示例15: selection_changed
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QListWidget [as 别名]
def selection_changed(self):
"""
A scenario title has been selected in the list.
"""
# get selected file
row = self.list.currentRow() # only useful if QListWidget does not sort by itself
scenario_file = self.scenario_files[row]
# emit title selected signal
self.title_selected.emit(scenario_file)