python中side什么意思_关于python:PyQt / PySide中是否有默认图标?

static PySide.QtGui.QIcon.fromTheme(name[, fallback=QIcon()])

Parameters:

name – unicode

fallback – PySide.QtGui.QIcon

Return type:

PySide.QtGui.QIcon

Returns the PySide.QtGui.QIcon corresponding to name in the current icon theme. If no such icon is found in the current theme

fallback is returned instead.

The latest version of the freedesktop icon specification and naming specification can be obtained here:

http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html

http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html

To fetch an icon from the current icon theme:

undoicon = QIcon.fromTheme("edit-undo")

Or if you want to provide a guaranteed fallback for platforms that do not support theme icons, you can use the second argument:

undoicon = QIcon.fromTheme("edit-undo", QIcon(":/undo.png"))

Note

By default, only X11 will support themed icons. In order to use themed icons on Mac and Windows, you will have to bundle a compliant theme in one of your PySide.QtGui.QIcon.themeSearchPaths() and set the appropriate PySide.QtGui.QIcon.themeName() .

See also

PySide.QtGui.QIcon.themeName()

PySide.QtGui.QIcon.setThemeName()

PySide.QtGui.QIcon.themeSearchPaths()

< /块引用>

哦!我很兴奋终于找到了一个标准qt图标的列表,但是第二个链接现在似乎被破坏了。有什么更新吗?

@Michaelscheper如果你没有收到我更新答案的通知,答案已经用新链接和相关文本更新。

还有另一种方法可以使用默认样式中的标准pixmap访问pyqt/pyside中的一些标准内置图标。例如,下面创建一个用于打开文件的图标:

self.style().standardIcon(QtGui.QStyle.SP_DialogOpenButton)

有关标准像素地图的完整列表,请参见:

http://srinikom.github.io/pyside-docs/pyside/qtgui/qstyle.html pyside.qtgui.pyside.qtgui.qstyle.standardpixmap

self是指QtWidgets.QApplication(qt5)或QtGui.QApplication(qt4),如果你想在self不是上述的情况下使用。

很遗憾,这些SP_图标如此有限。我希望他们能在名单上多加一些。

我不认为这是特定于任何绑定的,您可以查看qt常规文档

看看这里和这里

相关问题

我一直找不到标准图标的图像,所以以后参考:http://nukesaq88.hatenablog.com/entry/2013/04/12/005525

我使用的代码(pyqt4,pyside可能类似):

# In method of QMainWindow subclass

stdicon = self.style().standardIcon

style = QtGui.QStyle

reload_foo = QtGui.QAction(stdicon(style.SP_BrowserReload), '&Reload', self)

如果(显然是自动生成的)qt文档在standardicons枚举表中有图片,那就太好了…

另一个使用标准图标的pyqt5示例(eqzx的答案对我不起作用):

from PyQt5.QtWidgets import QApplication, QStyle

from PyQt5.QtGui import QIcon

desktop_icon = QIcon(QApplication.style().standardIcon(QStyle.SP_DesktopIcon)

在PyQt5中,有一个简单的例子,创建一个带有播放图标的按钮:

play_button = QtGui.QPushButton('Play video')

play_button.setIcon(QtGui.QApplication.style().standardIcon(QtGui.QStyle.SP_MediaPlay))

qt5文档提供了可能的sp("标准pixmap")图标列表。见enum QStyle::StandardPixmap这里:http://doc.qt.io/qt-5/qstyle.html

你说真的吗?那是Pyqt4而不是Pyqt5。

在pyqt中,窗口图标默认为qt徽标。我认为您必须在GUI中找到自己的图标。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值