GithubHelp home page GithubHelp logo

desty2k / qrainbowstylesheet Goto Github PK

View Code? Open in Web Editor NEW
13.0 1.0 2.0 31.61 MB

A customizable style sheet for QtWidgets application

License: Other

Python 98.94% SCSS 0.90% HTML 0.15%
aero pyqt5 pyside2 qtpy frameless-windows stylesheets cross-platform

qrainbowstylesheet's Introduction

QRainbowStyleSheet

Latest PyPI version Supported python versions Build Status Docs Status License: MIT License: CC BY 4.0 Conduct

The most complete customizable stylesheet for Qt application (PySide2, PyQt5, QtPy, Qt.Py).

Preview

From version v0.8 qrainbowstyle.windows module supports native Windows calls. Features:

  • Borders snapping
  • Minimize, restore, close animations
  • Size grips on borders
  • Frame shadow
  • Aero shake

On Linux and Darwin qrainbowstyle will load class with its own implementation of these features. Due to a bug in Qt, window minimizing is not supported on MacOS.

Frameless windows

https://raw.githubusercontent.com/desty2k/QRainbowStyleSheet/master/images/frameless_window_v3.png

Installation

From PyPI: Get the latest stable version of qrainbowstyle package using pip (preferable):

pip install qrainbowstyle

From code: Download/clone the project, go to qrainbowstyle folder then:

  • You can use the setup script and pip install.

    pip install .
  • Or, you can use the setup script with Python:

    python setup.py install

Usage

Frameless windows

import os
import sys
import qrainbowstyle
import qrainbowstyle.windows

from qtpy.QtWidgets import QApplication
from qtpy.QtCore import Qt

QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)

app = QApplication(sys.argv)
app.setStyleSheet(qrainbowstyle.load_stylesheet(style="oceanic"))

# Package options
# qrainbowstyle.alignButtonsLeft()
# qrainbowstyle.userDarwinButtons()
qrainbowstyle.setAppName("My new application")
qrainbowstyle.setAppIcon("/path/to/icon.ico")

# Create frameless mainwindow
win = qrainbowstyle.windows.FramelessWindow()

# Example of using signals
win.closeClicked.connect(lambda: print("Close clicked!"))

# Create content widget and pass reference to main window
widget = SomeWidget(win)

# Add widget to main window and show it
win.addContentWidget(widget)
win.show()

sys.exit(app.exec())

Style sheet

import os
import sys
import qrainbowstyle

# set the environment variable to use a specific wrapper
# it can be set to pyqt, pyqt5, or pyside2
# you do not need to use QtPy to set this variable
os.environ['QT_API'] = 'pyqt5'

# import from QtPy instead of doing it directly
# note that QtPy always uses PyQt5 API
from qtpy import QtWidgets

# create the application and the main window
app = QtWidgets.QApplication(sys.argv)
window = QtWidgets.QMainWindow()

# setup stylesheet
# the default system in qrainbowstyle uses qtpy environment variable
app.setStyleSheet(qrainbowstyle.load_stylesheet())

# run
window.show()
app.exec_()

If you are using PyQt5 directly, see the complete example

import sys
import qrainbowstyle
from PyQt5.QtWidgets import QApplication, QMainWindow

# create the application and the main window
app = QApplication(sys.argv)
window = QMainWindow()

# setup stylesheet
app.setStyleSheet(qrainbowstyle.load_stylesheet_pyqt5())
# or in new API
app.setStyleSheet(qrainbowstyle.load_stylesheet(qt_api='pyqt5'))

# run
window.show()
app.exec_()

Here is an example using PySide2

import sys
import qrainbowstyle
from Pyside2.QtWidgets import QApplication, QMainWindow

# create the application and the main window
app = QApplication(sys.argv)
window = QMainWindow()

# setup stylesheet
app.setStyleSheet(qrainbowstyle.load_stylesheet_pyside2())
# or in new API
app.setStyleSheet(qrainbowstyle.load_stylesheet(qt_api='pyside2'))

# run
window.show()
app.exec_()

If you are using Qt.py, which is different from qtpy, you should install qtpy then set both to the same binding.

Available styles

Currently available styles are:

  • Oceanic
  • QDarkStyle3
  • QDarkstyle3Light
  • LightOrange
  • DarkOrange
  • QDarkStyle (original)

Select style by using style= keyword argument

qrainbowstyle.load_stylesheet(style="lightorange")

Widgets

In v0.6 I added a few new widgets which automatically load colors from current stylesheet's palette.

GoogleMapsView

GoogleMapsView allows to load Google Maps to application. Supports creating markers and polylines. Call handler captures all map/markers/polylines actions such as map move or marker click/double click.

https://raw.githubusercontent.com/desty2k/QRainbowStyleSheet/master/images/frameless_mainwindow_google_maps_example.png

StylePicker

StylePicker is small widget used to change stylesheet without restarting application. Only styles generated by QRainbowStyle are supported. Widget is available in 3 versions: horizontal, vertical and grid.

https://raw.githubusercontent.com/desty2k/QRainbowStyleSheet/master/images/frameless_mainwindow_color_picker_example.png

QRoundProgressBar

Modified version of https://github.com/ozmartian/QRoundProgressBar. I replaced PyQt5 imports with qtpy and fixed widget background.

https://raw.githubusercontent.com/desty2k/QRainbowStyleSheet/master/images/frameless_mainwindow_round_progress_bar.png

QtWaitingSpinner

Modified version of https://github.com/fbjorn/QtWaitingSpinner. Added fade out and fade in. Spinner designer can be found in qrainbowstyle/widgets/QtWaitingSpinner/designer.py

https://raw.githubusercontent.com/desty2k/QRainbowStyleSheet/master/images/waiting_spinner_designer.png

Building your own style sheet

Download/clone the project, go to qrainbowstyle folder then:

  1. Create new style in palette.py by subclassing BasePalette. New palette should have unique name, for example DeepBluePalette

  2. Override default colors by your own. Example:

    class DeepBluePalette(BasePalette):
        COLOR_BACKGROUND_1 = "#263238"
        COLOR_BACKGROUND_2 = "#2f4048"
        COLOR_BACKGROUND_3 = "#34474f"
        COLOR_BACKGROUND_4 = "#394d57"
        COLOR_BACKGROUND_5 = "#3d545f"
        COLOR_BACKGROUND_6 = "#425b67"
    
        COLOR_TEXT_1 = Gray.B130
        COLOR_TEXT_2 = Gray.B110
        COLOR_TEXT_3 = Gray.B90
        COLOR_TEXT_4 = Gray.B80
    
        COLOR_ACCENT_1 = "#0a4542"
        COLOR_ACCENT_2 = "#136460"
        COLOR_ACCENT_3 = "#097D74"
        COLOR_ACCENT_4 = "#56BFBA"
        COLOR_ACCENT_5 = "#C4D6DB"
    
        TITLE_BAR_BACKGROUND_COLOR = COLOR_ACCENT_3
        TITLE_BAR_BUTTONS_HOVER_COLOR = COLOR_ACCENT_4
        TITLE_BAR_BUTTONS_DISABLED_COLOR = COLOR_ACCENT_1
        TITLE_BAR_TEXT_COLOR = COLOR_TEXT_1
    
        OPACITY_TOOLTIP = 230
  3. Generate resources for your style by running scripts/process_qrc.py

  4. Install package by running:

    pip install .
  5. To use style sheet in your application:

    import qrainbowstyle
    
    app = QApplication(sys.argv)
    app.setStyleSheet(qrainbowstyle.load_stylesheet(style="deepblue")

What is new?

Starting with new package name, I added frameless widnows and possibility to design your own stylesheet. I added few new SVG icons such as title bar icons.

  • 0.6 - widget subpackage
  • 0.8 - Windows API support
  • 0.9 - modern style for frameless windows, full support for new color system

Changelog

Please, see CHANGES file.

License

This project is licensed under the MIT license. Images contained in this project are licensed under CC-BY license.

For more information see LICENSE file.

Authors

For more information see AUTHORS file.

Contributing

Most widgets have been styled. If you find a widget that has not been style, just open an issue on the issue tracker or, better, submit a pull request.

If you want to contribute, see CONTRIBUTING file.

qrainbowstylesheet's People

Contributors

aaiyer avatar aitormoreno avatar bitdeli-chef avatar colinduquesnoy avatar dependabot[bot] avatar desty2k avatar devinacker avatar dpizetta avatar fieldofview avatar goanpeca avatar kchnst avatar mhendricks avatar mowoolli avatar mstuttgart avatar nikita-y avatar pkev avatar polygamma avatar powermanwxy avatar raincode avatar sawt00th avatar svenevs avatar tmosley-nc avatar tsilia avatar vladimir-kraus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

almaz114 khangthk

qrainbowstylesheet's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.