Skip to content

Added suport for PySide6 #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Qt5 comes with a huge number of widgets built-in, from simple text boxes to digital displays, vector graphics canvas and a full-blown web browser. While you can build perfectly functional applications with the built-in widgets, sometimes your applications will need a *more*.

This repo contains a library of [custom Python Qt5 widgets](https://www.learnpyqt.com/widgets/) which are free to use in your own applications. Widgets are compatible with both PyQt5 and PySide2 (Qt for Python). Currently the repository includes -
This repo contains a library of [custom Python Qt5 widgets](https://www.learnpyqt.com/widgets/) which are free to use in your own applications. Widgets are compatible with both PyQt5 and PySide2 (Qt for Python) and PySide6. Currently the repository includes -

| Widgets | Library |
| :---: | :---: |
Expand Down
8 changes: 6 additions & 2 deletions qtwidgets/color_duo/color_duo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
if 'PyQt5' in sys.modules:
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import Qt, pyqtSignal as Signal

else:
elif 'PySide2' in sys.modules:
from PySide2 import QtCore, QtGui, QtWidgets
from PySide2.QtCore import Qt, Signal

else:
from PySide6 import QtCore, QtGui, QtWidgets
from PySide6.QtCore import Qt, Signal


class ColorDuo(QtWidgets.QPushButton):
'''
Expand Down
26 changes: 26 additions & 0 deletions qtwidgets/color_duo/demo_pyside6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from PySide6 import QtWidgets
from qtwidgets import ColorButton


class Window(QtWidgets.QMainWindow):

def __init__(self):
super().__init__()

palette = ColorButton()
palette.colorChanged.connect(self.show_selected_color)
self.setCentralWidget(palette)

def show_selected_color(self, c):
print("Selected: {}".format(c))


app = QtWidgets.QApplication([])
w = Window()
w.show()
app.exec_()





7 changes: 5 additions & 2 deletions qtwidgets/colorbutton/colorbutton.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import Qt, pyqtSignal as Signal

else:
elif 'PySide2' in sys.modules:
from PySide2 import QtCore, QtGui, QtWidgets
from PySide2.QtCore import Qt, Signal


else:
from PySide6 import QtCore, QtGui, QtWidgets
from PySide6.QtCore import Qt, Signal


class ColorButton(QtWidgets.QPushButton):
Expand Down
26 changes: 26 additions & 0 deletions qtwidgets/colorbutton/demo_pyside6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from PySide6 import QtWidgets
from qtwidgets import ColorButton


class Window(QtWidgets.QMainWindow):

def __init__(self):
super().__init__()

palette = ColorButton(color='red')
palette.colorChanged.connect(self.show_selected_color)
self.setCentralWidget(palette)

def show_selected_color(self, c):
print("Selected: {}".format(c))


app = QtWidgets.QApplication([])
w = Window()
w.show()
app.exec_()





26 changes: 26 additions & 0 deletions qtwidgets/equalizer/demo_pyside6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from PySide6 import QtCore, QtGui, QtWidgets
from equalizer import Equalizer


class Window(QtWidgets.QMainWindow):

def __init__(self):
super().__init__()

palette = Palette('paired12')
palette.selected.connect(self.show_selected_color)
self.setCentralWidget(palette)

def show_selected_color(self, c):
print("Selected: {}".format(c))


app = QtWidgets.QApplication([])
w = Window()
w.show()
app.exec_()





36 changes: 36 additions & 0 deletions qtwidgets/equalizer_bar/demo_pyside6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from PySide6 import QtCore, QtWidgets
from qtwidgets import EqualizerBar

import random


class Window(QtWidgets.QMainWindow):

def __init__(self):
super().__init__()

self.equalizer = EqualizerBar(5, ['#0C0786', '#40039C', '#6A00A7', '#8F0DA3', '#B02A8F', '#CA4678', '#E06461',
'#F1824C', '#FCA635', '#FCCC25', '#EFF821'])
self.setCentralWidget(self.equalizer)

self._timer = QtCore.QTimer()
self._timer.setInterval(100)
self._timer.timeout.connect(self.update_values)
self._timer.start()

def update_values(self):
self.equalizer.setValues([
min(100, v+random.randint(0, 50) if random.randint(0, 5) > 2 else v)
for v in self.equalizer.values()
])


app = QtWidgets.QApplication([])
w = Window()
w.show()
app.exec_()





7 changes: 6 additions & 1 deletion qtwidgets/equalizer_bar/equalizer_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@
from PyQt5.QtCore import Qt
from PyQt5.QtCore import pyqtSignal as Signal

else:
elif 'PySide2' in sys.modules:
from PySide2 import QtCore, QtGui, QtWidgets
from PySide2.QtCore import Qt
from PySide2.QtCore import Signal

else:
from PySide6 import QtCore, QtGui, QtWidgets
from PySide6.QtCore import Qt
from PySide6.QtCore import Signal


class EqualizerBar(QtWidgets.QWidget):
Expand Down
26 changes: 26 additions & 0 deletions qtwidgets/filebrowser/demo_pyside6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from PySide6 import QtCore, QtGui, QtWidgets
from qtwidgets import FileBrowser


class Window(QtWidgets.QMainWindow):

def __init__(self):
super().__init__()

palette = Palette('paired12')
palette.selected.connect(self.show_selected_color)
self.setCentralWidget(palette)

def show_selected_color(self, c):
print("Selected: {}".format(c))


app = QtWidgets.QApplication([])
w = Window()
w.show()
app.exec_()





23 changes: 23 additions & 0 deletions qtwidgets/gradient/demo_pyside6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from PySide6 import QtCore, QtGui, QtWidgets
from qtwidgets import Gradient


class Window(QtWidgets.QMainWindow):

def __init__(self):
super().__init__()

gradient = Gradient()
gradient.setGradient([(0, 'black'), (1, 'green'), (0.5, 'red')])
self.setCentralWidget(gradient)


app = QtWidgets.QApplication([])
w = Window()
w.show()
app.exec_()





8 changes: 6 additions & 2 deletions qtwidgets/gradient/gradient.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
from PyQt5.QtCore import Qt
from PyQt5.QtCore import pyqtSignal as Signal

else:
elif 'PySide2' in sys.modules:
from PySide2 import QtCore, QtGui, QtWidgets
from PySide2.QtCore import Qt
from PySide2.QtCore import Signal


else:
from PySide6 import QtCore, QtGui, QtWidgets
from PySide6.QtCore import Qt
from PySide6.QtCore import Signal

class Gradient(QtWidgets.QWidget):

Expand Down
24 changes: 24 additions & 0 deletions qtwidgets/paint/demo_pyside6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from PySide6 import QtCore, QtGui, QtWidgets
from qtwidgets import Paint


class Window(QtWidgets.QMainWindow):

def __init__(self):
super().__init__()

paint = Paint(300, 300)
paint.setPenWidth(5)
paint.setPenColor('#EB5160')
self.setCentralWidget(paint)


app = QtWidgets.QApplication([])
w = Window()
w.show()
app.exec_()





5 changes: 4 additions & 1 deletion qtwidgets/paint/paint.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import Qt

else:
elif 'PySide2' in sys.modules:
from PySide2 import QtCore, QtGui, QtWidgets
from PySide2.QtCore import Qt

else:
from PySide6 import QtCore, QtGui, QtWidgets
from PySide6.QtCore import Qt

class Paint(QtWidgets.QLabel):

Expand Down
26 changes: 26 additions & 0 deletions qtwidgets/palette/demo_pyside6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from PySide6 import QtCore, QtGui, QtWidgets
from qtwidgets import PaletteGrid, PaletteHorizontal, PaletteVertical


class Window(QtWidgets.QMainWindow):

def __init__(self):
super().__init__()

palette = PaletteGrid('17undertones') # or PaletteHorizontal, or PaletteVertical
palette.selected.connect(self.show_selected_color)
self.setCentralWidget(palette)

def show_selected_color(self, c):
print("Selected: {}".format(c))


app = QtWidgets.QApplication([])
w = Window()
w.show()
app.exec_()





9 changes: 6 additions & 3 deletions qtwidgets/palette/palette.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtCore import Qt, pyqtSignal as Signal

else:
elif 'PySide2' in sys.modules:
from PySide2 import QtCore, QtWidgets
from PySide2.QtCore import Signal

from PySide2.QtCore import Qt

else:
from PySide6 import QtCore, QtWidgets
from PySide6.QtCore import Qt, Signal

PALETTES = {
# bokeh paired 12
'paired12':['#000000', '#a6cee3', '#1f78b4', '#b2df8a', '#33a02c', '#fb9a99', '#e31a1c', '#fdbf6f', '#ff7f00', '#cab2d6', '#6a3d9a', '#ffff99', '#b15928', '#ffffff'],
Expand Down
22 changes: 22 additions & 0 deletions qtwidgets/passwordedit/demo_pyside6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from PySide6 import QtCore, QtGui, QtWidgets
from qtwidgets import PasswordEdit


class Window(QtWidgets.QMainWindow):

def __init__(self):
super().__init__()

password = PasswordEdit()
self.setCentralWidget(password)


app = QtWidgets.QApplication([])
w = Window()
w.show()
app.exec_()





7 changes: 6 additions & 1 deletion qtwidgets/passwordedit/password.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@
from PyQt5.QtCore import pyqtSignal as Signal
from . import resources_pyqt5

else:
elif 'PySide2' in sys.modules:
from PySide2 import QtCore, QtGui, QtWidgets
from PySide2.QtCore import Qt
from PySide2.QtCore import Signal
from . import resources_pyside2

else:
from PySide6 import QtCore, QtGui, QtWidgets
from PySide6.QtCore import Qt
from PySide6.QtCore import Signal
#from . import resources_pyside6

class PasswordEdit(QtWidgets.QLineEdit):
"""
Expand Down
15 changes: 15 additions & 0 deletions qtwidgets/power_bar/demo_pyside6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from PySide6 import QtCore, QtGui, QtWidgets
from qtwidgets import PowerBar


app = QtWidgets.QApplication([])
volume = PowerBar(["#053061", "#2166ac", "#4393c3", "#92c5de", "#d1e5f0", "#f7f7f7", "#fddbc7", "#f4a582", "#d6604d", "#b2182b", "#67001f"])
volume.setBarSolidPercent(0.8)
volume.setBarPadding(5)
volume.show()
app.exec_()





Loading