本文整理汇总了Python中AnyQt.QtGui.QIcon.addFile方法的典型用法代码示例。如果您正苦于以下问题:Python QIcon.addFile方法的具体用法?Python QIcon.addFile怎么用?Python QIcon.addFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtGui.QIcon
的用法示例。
在下文中一共展示了QIcon.addFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from AnyQt.QtGui import QIcon [as 别名]
# 或者: from AnyQt.QtGui.QIcon import addFile [as 别名]
def get(self, name, default=None):
path = self.find(name)
if not path:
path = self.find(self.DEFAULT_ICON if default is None else default)
if not path:
raise IOError(2, "Cannot find %r in %s" %
(name, self.search_paths()))
if self.is_icon_glob(path):
icons = self.icon_glob(path)
else:
icons = [path]
from AnyQt.QtGui import QIcon
icon = QIcon()
for path in icons:
icon.addFile(path)
return icon
示例2: get
# 需要导入模块: from AnyQt.QtGui import QIcon [as 别名]
# 或者: from AnyQt.QtGui.QIcon import addFile [as 别名]
def get(self, name, default=None):
if name:
path = self.find(name)
else:
path = None
if path is None:
path = self.find(self.DEFAULT_ICON if default is None else default)
if path is None:
return QIcon()
if self.is_icon_glob(path):
icons = self.icon_glob(path)
else:
icons = [path]
icon = QIcon()
for path in icons:
icon.addFile(path)
return icon
示例3: set_basic_layout
# 需要导入模块: from AnyQt.QtGui import QIcon [as 别名]
# 或者: from AnyQt.QtGui.QIcon import addFile [as 别名]
def set_basic_layout(self):
"""Provide the basic widget layout
Which parts are created is regulated by class attributes
`want_main_area`, `want_control_area`, `want_message_bar` and
`buttons_area_orientation`, the presence of method `send_report`
and attribute `graph_name`.
"""
self.setLayout(QVBoxLayout())
self.layout().setContentsMargins(2, 2, 2, 2)
if not self.resizing_enabled:
self.layout().setSizeConstraint(QVBoxLayout.SetFixedSize)
self.want_main_area = self.want_main_area or self.graph_name
self._create_default_buttons()
self._insert_splitter()
if self.want_control_area:
self._insert_control_area()
if self.want_main_area:
self._insert_main_area()
if self.want_message_bar:
# Use a OverlayWidget for status bar positioning.
c = OverlayWidget(self, alignment=Qt.AlignBottom)
c.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
c.setWidget(self)
c.setLayout(QVBoxLayout())
c.layout().setContentsMargins(0, 0, 0, 0)
sb = QStatusBar()
sb.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Maximum)
sb.setSizeGripEnabled(self.resizing_enabled)
c.layout().addWidget(sb)
help = self.__help_action
icon = QIcon(gui.resource_filename("icons/help.svg"))
icon.addFile(gui.resource_filename("icons/help-hover.svg"), mode=QIcon.Active)
help_button = SimpleButton(
icon=icon,
toolTip="Show widget help", visible=help.isVisible(),
)
@help.changed.connect
def _():
help_button.setVisible(help.isVisible())
help_button.setEnabled(help.isEnabled())
help_button.clicked.connect(help.trigger)
sb.addWidget(help_button)
if self.graph_name is not None:
icon = QIcon(gui.resource_filename("icons/chart.svg"))
icon.addFile(gui.resource_filename("icons/chart-hover.svg"), mode=QIcon.Active)
b = SimpleButton(
icon=icon,
toolTip="Save Image",
)
b.clicked.connect(self.save_graph)
sb.addWidget(b)
if hasattr(self, "send_report"):
icon = QIcon(gui.resource_filename("icons/report.svg"))
icon.addFile(gui.resource_filename("icons/report-hover.svg"), mode=QIcon.Active)
b = SimpleButton(
icon=icon,
toolTip="Report"
)
b.clicked.connect(self.show_report)
sb.addWidget(b)
self.message_bar = MessagesWidget(self)
self.message_bar.setSizePolicy(QSizePolicy.Preferred,
QSizePolicy.Preferred)
pb = QProgressBar(maximumWidth=120, minimum=0, maximum=100)
pb.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Ignored)
pb.setAttribute(Qt.WA_LayoutUsesWidgetRect)
pb.setAttribute(Qt.WA_MacMiniSize)
pb.hide()
sb.addPermanentWidget(pb)
sb.addPermanentWidget(self.message_bar)
def statechanged():
pb.setVisible(bool(self.processingState) or self.isBlocking())
if self.isBlocking() and not self.processingState:
pb.setRange(0, 0) # indeterminate pb
elif self.processingState:
pb.setRange(0, 100) # determinate pb
self.processingStateChanged.connect(statechanged)
self.blockingStateChanged.connect(statechanged)
@self.progressBarValueChanged.connect
def _(val):
pb.setValue(int(val))
# Reserve the bottom margins for the status bar
margins = self.layout().contentsMargins()
margins.setBottom(sb.sizeHint().height())
self.setContentsMargins(margins)