def add_tooltip_icon(self, text: str): label = widgets.Label(text) label.setToolTip(text) icon = iconprovider.get_icon("mdi.help-circle-outline") pixmap = icon.pixmap(20, 20) label.setPixmap(pixmap) self.box.add(label)
def set_icon(self, icon: types.IconType) -> None: """Set the window icon. Args: icon: icon to use """ icon = iconprovider.get_icon(icon, color=colors.WINDOW_ICON_COLOR) self.setWindowIcon(icon)
def set_icon(self, icon: types.IconType): """Set the icon for the action. Args: icon: icon to use """ icon = iconprovider.get_icon(icon) self.setIcon(icon)
def set_icon(self, icon: types.IconType): """Set the system tray icon. Args: icon: icon to use """ icon = iconprovider.get_icon(icon) self.setIcon(icon)
def set_clean_icon(self, icon: types.IconType): """Set the icon for the clean button. Args: icon: icon to use """ icon = iconprovider.get_icon(icon) self.setCleanIcon(icon)
def add(self, label: str, data=NoData, icon: types.IconType = None): if data is NoData: data = label if icon is not None: icon = iconprovider.get_icon(icon) self.addItem(gui.Icon(icon), label, userData=data) else: self.addItem(label, userData=data)
def __init__(self): super().__init__() self.folder_icon = iconprovider.get_icon("mdi.folder") self.text_icon = iconprovider.get_icon("mdi.file-document") self.file_icon = iconprovider.get_icon("mdi.file") self.desktop_icon = iconprovider.get_icon("mdi.desktop-mac-dashboard") self.computer_icon = iconprovider.get_icon("mdi.desktop-classic") self.trashcan_icon = iconprovider.get_icon("mdi.trash-can") self.drive_icon = iconprovider.get_icon("mdi.harddisk") self.network_icon = iconprovider.get_icon("mdi.folder-network")
def set_icon(self, icon: types.IconType, column: int = 0): """Set the icon for the action. Args: icon: icon to use column: column """ icon = iconprovider.get_icon(icon) self.setIcon(column, icon)
def set_icon(self, _icon: types.IconType): """Set a new icon(). Parameters ---------- _icon: qtawesome.icon icon to set """ self._icon = iconprovider.get_icon(_icon) self.setPixmap(self._icon.pixmap(self._size))
def add_item( self, name: str = "", icon: types.IconType = None, data: dict | None = None, foreground: QtGui.QBrush | None = None, background: QtGui.QBrush | None = None, font: QtGui.QFont | None = None, selectable: bool = True, enabled: bool = True, editable: bool = False, status_tip: str | None = None, tool_tip: str | None = None, whats_this: str | None = None, # text_alignment: Optional[str] = None, checkstate: constants.StateStr | None = None, flags: QtCore.Qt.ItemFlags | None = None, size_hint: types.SizeType | None = None, is_user_type: bool = False, ) -> gui.StandardItem: item = gui.StandardItem(name) if icon is not None: icon = iconprovider.get_icon(icon) item.setIcon(icon) if data is not None: for k, v in data.items(): item.setData(v, k) if foreground is not None: item.setForeground(foreground) if background is not None: item.setBackground(background) if font is not None: item.setFont(font) if flags is not None: item.setFlags(flags) if enabled: item.setEnabled(enabled) if editable: item.setEditable(editable) if selectable: item.setSelectable(selectable) if status_tip: item.setStatusTip(status_tip) if tool_tip: item.setToolTip(tool_tip) if whats_this: item.setWhatsThis(whats_this) if size_hint is not None: item.set_size_hint(size_hint) if checkstate is not None: item.set_checkstate(checkstate) self.appendRow([item]) return item
def add_widget( self, widget: QtWidgets.QWidget, title: str | None = None, icon: types.IconType = None, ): if title is None: title = widget.objectName() if icon: icon = iconprovider.get_icon(icon) self.addItem(widget, icon, title) else: self.addItem(widget, title)
def add_action( self, label: str, icon: types.IconType = None, callback: Callable | None = None, checkable: bool = False, ) -> QtWidgets.QAction: icon = iconprovider.get_icon(icon) action = self.addAction(icon, label) if callback is not None: action.triggered.connect(callback) if checkable: action.setCheckable(True) return action
def show_message( self, title: str, message: str = "", icon: types.IconType = None, timeout: int = 10, ): if icon is None: ico = gui.Icon() if icon in MESSAGE_ICONS: ico = MESSAGE_ICONS[icon] else: ico = iconprovider.get_icon(icon) self.showMessage(title, message, ico, timeout * 1000)
def add_item( self, name: str = "", icon: types.IconType = None, data: dict | None = None, foreground: QtGui.QBrush | None = None, background: QtGui.QBrush | None = None, font: QtGui.QFont | None = None, selected: bool = None, status_tip: str | None = None, tool_tip: str | None = None, whats_this: str | None = None, # text_alignment: Optional[str] = None, checkstate: constants.StateStr | None = None, flags: QtCore.Qt.ItemFlags | None = None, size_hint: types.SizeType | None = None, is_user_type: bool = False, ) -> widgets.ListWidgetItem: typ = 1 if is_user_type else 0 item = widgets.ListWidgetItem(name, self, typ) if icon is not None: icon = iconprovider.get_icon(icon) item.setIcon(icon) if data is not None: for k, v in data.items(): item.setData(k, v) if foreground is not None: item.setForeground(foreground) if background is not None: item.setBackground(background) if font is not None: item.setFont(font) if flags is not None: item.setFlags(flags) if selected: item.setSelected(selected) if status_tip: item.setStatusTip(status_tip) if tool_tip: item.setToolTip(tool_tip) if whats_this: item.setWhatsThis(whats_this) if size_hint is not None: item.set_size_hint(size_hint) if checkstate is not None: item.set_checkstate(checkstate) self.addItem(item) return item
def add_tab( self, item: QtWidgets.QWidget, title: str, icon: types.IconType = None, show: bool = False, shortcut: str | None = None, area: AreaStr = "top", ): self.area.box.add(item) # button = widgets.ToolButton() # button.set_text(title) # button.set_icon_size(40) # button.setFixedSize(80, 80) # button.set_icon(icon) # button.clicked.connect(lambda: self.area.box.setCurrentWidget(item)) # self.sidebar.addWidget(button) # self.sidebar.add_separator() if area == "top": act = widgets.Action( text=title, icon=icon, shortcut=shortcut, parent=self.sidebar, checkable=True, callback=lambda: self.set_tab(item), ) self.sidebar.insertAction(self.spacer_action, act) else: act = self.sidebar.add_action( label=title, icon=icon, callback=lambda: self.set_tab(item), checkable=True, ) button = self.sidebar.widgetForAction(act) button.setFixedWidth(self.BUTTON_WIDTH) if len(self.area.box) == 1: button.setChecked(True) self.button_map[item] = button self.icon_map[item] = iconprovider.get_icon(icon) if show: self.area.box.setCurrentWidget(item)
def update_actions(self): """Updates the list of actions.""" self.clear() self.recent_files_actions[:] = [] for file in self.manager.get_recent_files(): action = widgets.Action(self) action.setText(os.path.split(file)[1]) action.setToolTip(file) action.setStatusTip(file) action.setData(file) action.setIcon(self.icon_provider.icon(core.FileInfo(file))) action.triggered.connect(self._on_action_triggered) self.addAction(action) self.recent_files_actions.append(action) self.addSeparator() action_clear = widgets.Action(parent=self, text="Clear list") action_clear.triggered.connect(self.clear_recent_files) action_clear.setIcon(iconprovider.get_icon("fa.times-circle")) self.addAction(action_clear)
def __init__( self, text: str | None = None, tooltip: str = "", icon: types.IconType = "mdi.help-circle-outline", parent: QtWidgets.QWidget | None = None, ): super().__init__(parent=parent) self.set_layout("horizontal") self.label = widgets.Label(text) self.label.setMargin(10) self.label.set_size_policy(horizontal="minimum") self.tooltip = tooltip icon = iconprovider.get_icon(icon) self.icon = widgets.Label() self.icon.setToolTip(tooltip) self.icon.set_size_policy(horizontal="minimum") pixmap = icon.pixmap(20, 20) self.icon.setPixmap(pixmap) self.box.add(self.label) self.box.add(self.icon) self.box.setSpacing(0) self.box.addStretch()
def add_tab( self, item: QtWidgets.QWidget | QtWidgets.QLayout, label: str, icon: types.IconType = None, position: int | None = None, show: bool = False, ) -> int: if isinstance(item, QtWidgets.QLayout): widget = widgets.Widget() widget.set_layout(item) else: widget = item if position is None: position = len(self) if not icon: index = self.insertTab(position, widget, label) else: icon = iconprovider.get_icon(icon) index = self.insertTab(position, widget, icon, label) if show: self.setCurrentIndex(index) return index
def requestPixmap(self, id_: str, requested_size: QtCore.QSize): # type: ignore pix = iconprovider.get_icon(id_).pixmap(requested_size) return pix, pix.size()
def requestImage(self, id_: str, requested_size: QtCore.QSize): # type: ignore img = iconprovider.get_icon(id_).pixmap(requested_size).toImage() return img, img.size()
def set_icon(self, icon: types.IconType | IconStr): if icon in ICONS: self.setIcon(ICONS[icon]) else: ico = iconprovider.get_icon(icon) self.setIconPixmap(ico.get_pixmap(size=64))
def set_icon(self, icon: types.IconType) -> None: icon = iconprovider.get_icon(icon) self.setIcon(icon)
if self.selected_sample is not sample: self.selected_sample = sample self.selection_changed.emit(sample) else: sample.color = sample.def_color def get_scale(self) -> float: return self.duration / self.width() def set_background_color(self, color: types.ColorType): color = colors.get_color(color) self.background_color = color def set_text_color(self, color: types.ColorType): color = colors.get_color(color) self.text_color = color def set_text_font(self, font: QtGui.QFont): self.text_font = font if __name__ == "__main__": app = widgets.app() tl = Timeline(60, 60) icon = iconprovider.get_icon("mdi.folder") px = icon.pixmap(256, 256) sample = VideoSample(20, picture=px) tl += sample tl.show() app.main_loop()