def addSheetPushButtonClicked(self, checked):
if self.ui.addSheetLineEdit.text(): # If the text field isn't empty
newTreeItem = QListWidgetItem(self.ui.addSheetLineEdit.text(), self.ui.sheetListWidget)
newTreeItem.setData(Qt.UserRole, uuid.uuid4().int) # Add some uniquely identifying data to make it hashable
self.currentProject.newSheet(newTreeItem)
python类QListWidgetItem()的实例源码
def updateSheets(self):
if self.sheets is not None and self.ownsheet is not None:
self.listSheetItems = {}
self.listWidget.clear()
for sheetId in self.sheets:
if not sheetId == self.ownsheet:
newItem = QListWidgetItem(self.sheets[sheetId])
newItem.setToolTip(str(sheetId))
newItem.setData(Qt.UserRole, sheetId)
self.listSheetItems[sheetId] = newItem
self.listWidget.addItem(newItem)
if sheetId == self.selectedSheet:
boldFont = QFont()
boldFont.setBold(True)
newItem.setFont(boldFont)
def make_listwidget(choices):
listwidget = QtWidgets.QListWidget()
listwidget.setItemDelegate
for item in choices:
item = QtWidgets.QListWidgetItem(item)
listwidget.addItem(item)
return listwidget
def __init__(self, parent=None):
QtWidgets.QListWidget.__init__(self, parent)
self.parent = parent
self.setFocusPolicy(False)
self.horizontalScrollBar().setVisible(False)
# Customize the list widget
self.setIconSize(QtCore.QSize(60, 60))
# Icon only
self.settingItem = QtWidgets.QListWidgetItem(QtGui.QIcon(":/resources/result_setting.png"), "")
self.settingItem.setToolTip("Setting")
self.logItem = QtWidgets.QListWidgetItem(QtGui.QIcon(":/resources/result_log.png"), "")
self.logItem.setToolTip("Log")
self.tableItem = QtWidgets.QListWidgetItem(QtGui.QIcon(":/resources/result_table.png"), "")
self.tableItem.setToolTip("Results")
self.plotItem = QtWidgets.QListWidgetItem(QtGui.QIcon(":/resources/result_plot.png"), "")
self.plotItem.setToolTip("Plots")
self.addItem(self.settingItem)
self.addItem(self.logItem)
self.addItem(self.tableItem)
self.addItem(self.plotItem)
# Hide icon
self.settingItem.setHidden(True)
self.logItem.setHidden(True)
self.tableItem.setHidden(True)
self.plotItem.setHidden(True)
# Stylesheet
self.setStyleSheet("QListWidget{min-width:90px; background:#f7fafc;border:none;border-left: 2px solid #e9f0f5;}QListWidget::item{background: #f7fafc;background-origin: cotent;background-clip: margin;color: #000000;margin: 0 0 0 10px;padding: 25px 0 25px 0px;}QListWidget::item:selected{background: #bac3ef;position: fixed;}QLabel{background: transparent;border: none;}")
# Signal
self.currentRowChanged.connect(self.viewChange)
# Swith function
def set_recent_list(self) -> None:
recent_files = self.get_recent_files(self.recent_file)
if not recent_files:
no_recents = QtWidgets.QListWidgetItem("No Recent Projects", self.list_projects)
no_recents.setFlags(QtCore.Qt.NoItemFlags)
return None
for name, path in recent_files.items():
item = QtWidgets.QListWidgetItem('{name} :: {path}'.format(name=name, path=str(path)), self.list_projects)
item.setData(QtCore.Qt.UserRole, path)
item.setToolTip(str(path.resolve()))
self.list_projects.setCurrentRow(0)
return None
def set_selection(self, item: QtWidgets.QListWidgetItem, *args):
"""Called when a recent item is selected"""
self.project_path = get_project_file(item.data(QtCore.Qt.UserRole))
if not self.project_path:
# TODO: Fix this, when user selects item multiple time the statement is re-appended
item.setText("{} - Project Moved or Deleted".format(item.data(QtCore.Qt.UserRole)))
self.log.debug("Project path set to {}".format(self.project_path))
def __init__(self, deviceMap):
"""
Create dialog and fill it with labels from deviceMap
@param deviceMap: dict device string -> device label
"""
QDialog.__init__(self)
self.setupUi(self)
for deviceStr, label in deviceMap.items():
item = QListWidgetItem(label)
item.setData(Qt.UserRole, QVariant(deviceStr))
self.trezorList.addItem(item)
self.trezorList.setCurrentRow(0)
def create_panel_list(self):
""" Create the list of panels on the left.
"""
self.panel_list = []
for panel in api.panels.get():
self.panel_list.append(QtWidgets.QListWidgetItem(
panel["name"], self.panels))
def accept(self):
""" Called when "Ajouter" is clicked
"""
if self.name_input.text():
if not api.panels.add(self.name_input.text()):
gui.utils.error("Erreur", "Impossible d'ajouter le panel")
else:
self.panel_list.append(QtWidgets.QListWidgetItem(
self.name_input.text(), self.panels))
self.name_input.setText("")
def __init__(self, parent):
super().__init__(parent)
super().setSortingEnabled(True)
self.widgets = []
for user in users.get_list():
widget = QtWidgets.QListWidgetItem(user, self)
self.widgets.append(widget)
if self.widgets:
self.widgets[0].setSelected(True)
def refresh(self):
""" Refesh list and add user which are not present
"""
user_list = list(users.get_list())
# Add added users
for user in user_list:
if user not in [w.text() for w in self.widgets]:
self.widgets.append(QtWidgets.QListWidgetItem(user, self))
# Remove deleted users
for widget in self.widgets:
if widget.text() not in user_list:
item = self.takeItem(self.row(widget))
self.widgets.pop(self.widgets.index(widget))
del item
def __init__(self, cid, pid, name, cat_name, prices, percentage=None):
QtWidgets.QComboBox.__init__(self)
BaseProduct.__init__(self, cid, pid, name, cat_name, prices)
self.product_view = QtWidgets.QListWidget()
self.product_view.wheelEvent = self.on_wheel
self.setModel(self.product_view.model())
self.widgets = []
self.call = None
self.should_accept_adding_products = False
self.name_item = QtWidgets.QListWidgetItem("")
self.name_layout = QtWidgets.QHBoxLayout()
self.setLayout(self.name_layout)
if percentage:
self.name_label = QtWidgets.QLabel(f"{name} <span style=\"color: red; font-size: 7px\">{percentage} °</span>", self)
else:
self.name_label = QtWidgets.QLabel(name)
self.name_label.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
self.name_layout.addWidget(self.name_label)
self.product_view.addItem(self.name_item)
for price in prices:
widget = QtWidgets.QListWidgetItem(price)
widget.setTextAlignment(QtCore.Qt.AlignHCenter |
QtCore.Qt.AlignVCenter)
widget.setSizeHint(QtCore.QSize(100, 35))
self.product_view.addItem(widget)
self.setView(self.product_view)
self.activated.connect(self.callback)
self.product_view.pressed.connect(self.on_click)
def fill_store(self):
self.materials.clear()
print(get_materials_path())
all_files=find_materials()
for fl in all_files:
text=get_ref_text(os.path.join(get_materials_path(),fl,"n.omat"),html=False)
if text!=None:
itm = QListWidgetItem(os.path.basename(fl)+" "+text)
itm.setIcon(self.mat_icon)
itm.setToolTip(text)
self.materials.addItem(itm)
def _populate_app_list(self):
self.app_list.clear()
for app in self.apps:
item = QtWidgets.QListWidgetItem(app.name)
self.app_list.addItem(item)
def _app_dialog(self, item):
if isinstance(item, QtWidgets.QListWidgetItem):
app = next((app for app in self.apps if app.name == item.text()), None)
app_dialog = AppDialog(self.controller, app=app, parent=self)
else:
app_dialog = AppDialog(self.controller, parent=self)
app_dialog.app_changed.connect(self.add_or_update_app)
app_dialog.exec_()
def _populate_workset_list(self):
self.workset_list.clear()
self.worksets = self.controller.get_worksets()
for workset in self.worksets:
item = QtWidgets.QListWidgetItem(workset.name)
self.workset_list.addItem(item)
self.workset_list.itemDoubleClicked.connect(self.workset_dialog)
def workset_dialog(self, item):
if isinstance(item, QtWidgets.QListWidgetItem):
workset = next((workset
for workset
in self.worksets
if workset.name == item.text()),
None)
workset_dialog = WorksetDialog(self.controller, workset)
else:
workset_dialog = WorksetDialog(self.controller)
workset_dialog.exec_()
rest_action_list_wt.py 文件源码
项目:mindfulness-at-the-computer
作者: SunyataZero
项目源码
文件源码
阅读 23
收藏 0
点赞 0
评论 0
def update_gui(self):
self.updating_gui_bool = True
self.list_widget.clear()
for rest_action in model.RestActionsM.get_all():
rest_action_title_cll = RestQLabel(rest_action.title_str, rest_action.id_int)
list_item = QtWidgets.QListWidgetItem()
self.list_widget.addItem(list_item)
self.list_widget.setItemWidget(list_item, rest_action_title_cll)
# self.update_gui_details()
self.updating_gui_bool = False
def add_user(self, username, me=False):
self.textBrowser.append('<i>New user in the chat: {}</i>'.format(username))
_translate = QtCore.QCoreApplication.translate
item = QtWidgets.QListWidgetItem()
item.setText(_translate("MainWindow", username))
if me:
font = QtGui.QFont()
font.setBold(True)
item.setFont(font)
self.listWidget.addItem(item)