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中找到自己的图标。

### PyCharm 打开文件显示全的解决方案 当遇到PyCharm打开文件显示全的情况时,可以尝试以下几种方法来解决问题。 #### 方法一:清理缓存并重启IDE 有时IDE内部缓存可能导致文件加载异常。通过清除缓存再启动程序能够有效改善此状况。具体操作路径为`File -> Invalidate Caches / Restart...`,之后按照提示完成相应动作即可[^1]。 #### 方法二:调整编辑器字体设置 如果是因为字体原因造成的内容显示问题,则可以通过修改编辑区内的文字样式来进行修复。进入`Settings/Preferences | Editor | Font`选项卡内更改合适的字号大小以及启用抗锯齿功能等参数配置[^2]。 #### 方法三:检查项目结构配置 对于某些特定场景下的源码视图缺失现象,可能是由于当前工作空间未能正确识别全部模块所引起。此时应该核查Project Structure的Content Roots设定项是否涵盖了整个工程根目录;必要时可手动添加遗漏部分,并保存变更生效[^3]。 ```python # 示例代码用于展示如何获取当前项目的根路径,在实际应用中可根据需求调用该函数辅助排查问题 import os def get_project_root(): current_file = os.path.abspath(__file__) project_dir = os.path.dirname(current_file) while not os.path.exists(os.path.join(project_dir, '.idea')): parent_dir = os.path.dirname(project_dir) if parent_dir == project_dir: break project_dir = parent_dir return project_dir print(f"Current Project Root Directory is {get_project_root()}") ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值