【问题标题】:What are the all styles in PyQt5 [closed]PyQt5中的所有样式是什么[关闭]
【发布时间】:2021-09-13 04:25:45
【问题描述】:
我使用的是 Windows 11
我正在使用 PyQt5
所以我想获得不同操作系统中的所有样式
那么你们能帮我说出你的操作系统上可用的操作系统名称和样式吗?
您可以通过以下代码获取可用的样式:
import PyQt5.QtWidgets as QtWidgets
print(QtWidgets.QStyleFactory.keys())
但请确保您在系统中安装了 PyQt5,使用:“pip install PyQt5”命令
【问题讨论】:
标签:
python
pyqt5
python-3.9
【解决方案1】:
您可以在 github 上创建工作流以获取每个操作系统上的样式:
name: get all styles
on: [push]
jobs:
ci:
name: ${{ matrix.os.name }}
runs-on: ${{ matrix.os.runs-on }}
strategy:
fail-fast: false
matrix:
os:
- name: Windows
runs-on: windows-latest
- name: Linux
runs-on: ubuntu-latest
- name: MacOS
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
architecture: x64
- name: install pyqt5
run: python -m pip install pyqt5
- name: print styles
run: python -c "from PyQt5.QtWidgets import QStyleFactory; print(QStyleFactory.keys())"
输出:
-
窗户:
['windowsvista', 'Windows', 'Fusion']
-
Linux:
['Windows', 'Fusion']
-
MacOS
['macintosh', 'Windows', 'Fusion']
您还可以添加其他样式,正如我在 this post 中指出的那样。