https://github.com/yjg30737/pyqt-style-setter
PyQt style setter
https://github.com/yjg30737/pyqt-style-setter
pyqt pyqt5 python python3 python37
Last synced: about 1 year ago
JSON representation
PyQt style setter
- Host: GitHub
- URL: https://github.com/yjg30737/pyqt-style-setter
- Owner: yjg30737
- License: mit
- Created: 2022-03-02T01:32:38.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-07-11T22:48:16.000Z (almost 4 years ago)
- Last Synced: 2024-04-26T00:42:13.159Z (about 2 years ago)
- Topics: pyqt, pyqt5, python, python3, python37
- Language: Python
- Homepage:
- Size: 36.1 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pyqt-style-setter
PyQt style setter
## Note
Currently the only style you can set is dark-gray(pyqt-dark-gray-theme), light-gray(pyqt-light-gray-theme).
## Requirements
* PyQt5 >= 5.8
## Setup
`python -m pip install pyqt-style-setter`
## Included Packages
* pyqt-dark-gray-theme
* pyqt-light-gray-theme
* pyqt-svg-button - To exclude svg icon set button, also known as `SvgButton`. It should use its own style or else svg icon will be disappeared by overwritten style.
## Usage
* `StyleSetter.setWindowStyle(main_window: QWidget, theme: str = 'dark', exclude_type_lst: list = [])` - `main_window` is the widget which user want to set the style. `exclude_type_lst`'s items are excluded from applying style. Item type should be `type`(ex. `QAbstractButton`). Currently it only works for `QAbstractButton`.
## Example
※ I use the pyqt-timer's settings dialog as an example.
### PyQt default theme
```python
from PyQt5.QtWidgets import QApplication
from pyqt_timer.settingsDialog import SettingsDialog
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
window = SettingsDialog()
window.show()
app.exec_()
```

### Dark-gray theme
```python
from PyQt5.QtWidgets import QApplication
from pyqt_style_setter import StyleSetter
from pyqt_timer.settingsDialog import SettingsDialog
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
window = SettingsDialog()
StyleSetter.setWindowStyle(window) # add this
window.show()
app.exec_()
```

### Using this with pyqt-custom-titlebar-setter
```python
from PyQt5.QtWidgets import QApplication
from pyqt_custom_titlebar_setter import CustomTitlebarSetter
from pyqt_style_setter import StyleSetter
from pyqt_timer.settingsDialog import SettingsDialog
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
dialog = SettingsDialog()
StyleSetter.setWindowStyle(dialog)
titleBarWindow = CustomTitlebarSetter.getCustomTitleBarWindow(dialog, icon_filename='settings.svg')
titleBarWindow.show()
app.exec_()
```

For those who use macOS

## See Also
* qtsasstheme - using sass to set qt theme, bit more harder but far more flexible