mirror of
https://github.com/Wanderson-Magalhaes/PyOneDark_Qt_Widgets_Modern_GUI.git
synced 2026-06-21 18:14:18 +00:00
v1.0.1 Released
This commit is contained in:
committed by
GitHub
parent
a3952dad06
commit
c36a51579f
+70
-70
@@ -1,71 +1,71 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT WIDGETS
|
||||
# ADD here all custom widgets
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# PY WINDOW
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_window import PyWindow
|
||||
|
||||
# RESIZE GRIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_grips import PyGrips
|
||||
|
||||
# LEFT MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_left_menu import PyLeftMenu
|
||||
|
||||
# PY LEFT COLUMN
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_left_column import PyLeftColumn
|
||||
|
||||
# PY TITLE BAR
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_title_bar import PyTitleBar
|
||||
|
||||
# PY CREDITS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_credits_bar import PyCredits
|
||||
|
||||
# PY PUSH BUTTON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_push_button import PyPushButton
|
||||
|
||||
# PY TOGGLE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_toggle import PyToggle
|
||||
|
||||
# PY SLIDER
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_slider import PySlider
|
||||
|
||||
# PY CIRCULAR PROGRESS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_circular_progress import PyCircularProgress
|
||||
|
||||
# PY ICON BUTTON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_icon_button import PyIconButton
|
||||
|
||||
# PY LINE EDIT
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_line_edit import PyLineEdit
|
||||
|
||||
# PY TABLE WIDGET
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT WIDGETS
|
||||
# ADD here all custom widgets
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# PY WINDOW
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_window import PyWindow
|
||||
|
||||
# RESIZE GRIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_grips import PyGrips
|
||||
|
||||
# LEFT MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_left_menu import PyLeftMenu
|
||||
|
||||
# PY LEFT COLUMN
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_left_column import PyLeftColumn
|
||||
|
||||
# PY TITLE BAR
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_title_bar import PyTitleBar
|
||||
|
||||
# PY CREDITS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_credits_bar import PyCredits
|
||||
|
||||
# PY PUSH BUTTON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_push_button import PyPushButton
|
||||
|
||||
# PY TOGGLE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_toggle import PyToggle
|
||||
|
||||
# PY SLIDER
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_slider import PySlider
|
||||
|
||||
# PY CIRCULAR PROGRESS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_circular_progress import PyCircularProgress
|
||||
|
||||
# PY ICON BUTTON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_icon_button import PyIconButton
|
||||
|
||||
# PY LINE EDIT
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_line_edit import PyLineEdit
|
||||
|
||||
# PY TABLE WIDGET
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_table_widget import PyTableWidget
|
||||
@@ -1,19 +1,19 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# PY TITLE BAR
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# PY TITLE BAR
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_circular_progress import PyCircularProgress
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,114 +1,114 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
class PyCircularProgress(QWidget):
|
||||
def __init__(
|
||||
self,
|
||||
value = 0,
|
||||
progress_width = 10,
|
||||
is_rounded = True,
|
||||
max_value = 100,
|
||||
progress_color = "#ff79c6",
|
||||
enable_text = True,
|
||||
font_family = "Segoe UI",
|
||||
font_size = 12,
|
||||
suffix = "%",
|
||||
text_color = "#ff79c6",
|
||||
enable_bg = True,
|
||||
bg_color = "#44475a"
|
||||
):
|
||||
QWidget.__init__(self)
|
||||
|
||||
# CUSTOM PROPERTIES
|
||||
self.value = value
|
||||
self.progress_width = progress_width
|
||||
self.progress_rounded_cap = is_rounded
|
||||
self.max_value = max_value
|
||||
self.progress_color = progress_color
|
||||
# Text
|
||||
self.enable_text = enable_text
|
||||
self.font_family = font_family
|
||||
self.font_size = font_size
|
||||
self.suffix = suffix
|
||||
self.text_color = text_color
|
||||
# BG
|
||||
self.enable_bg = enable_bg
|
||||
self.bg_color = bg_color
|
||||
|
||||
# ADD DROPSHADOW
|
||||
def add_shadow(self, enable):
|
||||
if enable:
|
||||
self.shadow = QGraphicsDropShadowEffect(self)
|
||||
self.shadow.setBlurRadius(15)
|
||||
self.shadow.setXOffset(0)
|
||||
self.shadow.setYOffset(0)
|
||||
self.shadow.setColor(QColor(0, 0, 0, 80))
|
||||
self.setGraphicsEffect(self.shadow)
|
||||
|
||||
# SET VALUE
|
||||
def set_value(self, value):
|
||||
self.value = value
|
||||
self.repaint() # Render progress bar after change value
|
||||
|
||||
|
||||
# PAINT EVENT (DESIGN YOUR CIRCULAR PROGRESS HERE)
|
||||
def paintEvent(self, e):
|
||||
# SET PROGRESS PARAMETERS
|
||||
width = self.width() - self.progress_width
|
||||
height = self.height() - self.progress_width
|
||||
margin = self.progress_width / 2
|
||||
value = self.value * 360 / self.max_value
|
||||
|
||||
# PAINTER
|
||||
paint = QPainter()
|
||||
paint.begin(self)
|
||||
paint.setRenderHint(QPainter.Antialiasing) # remove pixelated edges
|
||||
paint.setFont(QFont(self.font_family, self.font_size))
|
||||
|
||||
# CREATE RECTANGLE
|
||||
rect = QRect(0, 0, self.width(), self.height())
|
||||
paint.setPen(Qt.NoPen)
|
||||
|
||||
# PEN
|
||||
pen = QPen()
|
||||
pen.setWidth(self.progress_width)
|
||||
# Set Round Cap
|
||||
if self.progress_rounded_cap:
|
||||
pen.setCapStyle(Qt.RoundCap)
|
||||
|
||||
# ENABLE BG
|
||||
if self.enable_bg:
|
||||
pen.setColor(QColor(self.bg_color))
|
||||
paint.setPen(pen)
|
||||
paint.drawArc(margin, margin, width, height, 0, 360 * 16)
|
||||
|
||||
# CREATE ARC / CIRCULAR PROGRESS
|
||||
pen.setColor(QColor(self.progress_color))
|
||||
paint.setPen(pen)
|
||||
paint.drawArc(margin, margin, width, height, -90 * 16, -value * 16)
|
||||
|
||||
# CREATE TEXT
|
||||
if self.enable_text:
|
||||
pen.setColor(QColor(self.text_color))
|
||||
paint.setPen(pen)
|
||||
paint.drawText(rect, Qt.AlignCenter, f"{self.value}{self.suffix}")
|
||||
|
||||
# END
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
class PyCircularProgress(QWidget):
|
||||
def __init__(
|
||||
self,
|
||||
value = 0,
|
||||
progress_width = 10,
|
||||
is_rounded = True,
|
||||
max_value = 100,
|
||||
progress_color = "#ff79c6",
|
||||
enable_text = True,
|
||||
font_family = "Segoe UI",
|
||||
font_size = 12,
|
||||
suffix = "%",
|
||||
text_color = "#ff79c6",
|
||||
enable_bg = True,
|
||||
bg_color = "#44475a"
|
||||
):
|
||||
QWidget.__init__(self)
|
||||
|
||||
# CUSTOM PROPERTIES
|
||||
self.value = value
|
||||
self.progress_width = progress_width
|
||||
self.progress_rounded_cap = is_rounded
|
||||
self.max_value = max_value
|
||||
self.progress_color = progress_color
|
||||
# Text
|
||||
self.enable_text = enable_text
|
||||
self.font_family = font_family
|
||||
self.font_size = font_size
|
||||
self.suffix = suffix
|
||||
self.text_color = text_color
|
||||
# BG
|
||||
self.enable_bg = enable_bg
|
||||
self.bg_color = bg_color
|
||||
|
||||
# ADD DROPSHADOW
|
||||
def add_shadow(self, enable):
|
||||
if enable:
|
||||
self.shadow = QGraphicsDropShadowEffect(self)
|
||||
self.shadow.setBlurRadius(15)
|
||||
self.shadow.setXOffset(0)
|
||||
self.shadow.setYOffset(0)
|
||||
self.shadow.setColor(QColor(0, 0, 0, 80))
|
||||
self.setGraphicsEffect(self.shadow)
|
||||
|
||||
# SET VALUE
|
||||
def set_value(self, value):
|
||||
self.value = value
|
||||
self.repaint() # Render progress bar after change value
|
||||
|
||||
|
||||
# PAINT EVENT (DESIGN YOUR CIRCULAR PROGRESS HERE)
|
||||
def paintEvent(self, e):
|
||||
# SET PROGRESS PARAMETERS
|
||||
width = self.width() - self.progress_width
|
||||
height = self.height() - self.progress_width
|
||||
margin = self.progress_width / 2
|
||||
value = self.value * 360 / self.max_value
|
||||
|
||||
# PAINTER
|
||||
paint = QPainter()
|
||||
paint.begin(self)
|
||||
paint.setRenderHint(QPainter.Antialiasing) # remove pixelated edges
|
||||
paint.setFont(QFont(self.font_family, self.font_size))
|
||||
|
||||
# CREATE RECTANGLE
|
||||
rect = QRect(0, 0, self.width(), self.height())
|
||||
paint.setPen(Qt.NoPen)
|
||||
|
||||
# PEN
|
||||
pen = QPen()
|
||||
pen.setWidth(self.progress_width)
|
||||
# Set Round Cap
|
||||
if self.progress_rounded_cap:
|
||||
pen.setCapStyle(Qt.RoundCap)
|
||||
|
||||
# ENABLE BG
|
||||
if self.enable_bg:
|
||||
pen.setColor(QColor(self.bg_color))
|
||||
paint.setPen(pen)
|
||||
paint.drawArc(margin, margin, width, height, 0, 360 * 16)
|
||||
|
||||
# CREATE ARC / CIRCULAR PROGRESS
|
||||
pen.setColor(QColor(self.progress_color))
|
||||
paint.setPen(pen)
|
||||
paint.drawArc(margin, margin, width, height, -90 * 16, -value * 16)
|
||||
|
||||
# CREATE TEXT
|
||||
if self.enable_text:
|
||||
pen.setColor(QColor(self.text_color))
|
||||
paint.setPen(pen)
|
||||
paint.drawText(rect, Qt.AlignCenter, f"{self.value}{self.suffix}")
|
||||
|
||||
# END
|
||||
paint.end()
|
||||
@@ -1,19 +1,19 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# PY CREDITS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# PY CREDITS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_credits import PyCredits
|
||||
@@ -1,95 +1,95 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# PY CREDITS BAR AND VERSION
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyCredits(QWidget):
|
||||
def __init__(
|
||||
self,
|
||||
copyright,
|
||||
version,
|
||||
bg_two,
|
||||
font_family,
|
||||
text_size,
|
||||
text_description_color,
|
||||
radius = 8,
|
||||
padding = 10
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
# PROPERTIES
|
||||
self._copyright = copyright
|
||||
self._version = version
|
||||
self._bg_two = bg_two
|
||||
self._font_family = font_family
|
||||
self._text_size = text_size
|
||||
self._text_description_color = text_description_color
|
||||
self._radius = radius
|
||||
self._padding = padding
|
||||
|
||||
# SETUP UI
|
||||
self.setup_ui()
|
||||
|
||||
def setup_ui(self):
|
||||
# ADD LAYOUT
|
||||
self.widget_layout = QHBoxLayout(self)
|
||||
self.widget_layout.setContentsMargins(0,0,0,0)
|
||||
|
||||
# BG STYLE
|
||||
style = f"""
|
||||
#bg_frame {{
|
||||
border-radius: {self._radius}px;
|
||||
background-color: {self._bg_two};
|
||||
}}
|
||||
.QLabel {{
|
||||
font: {self._text_size}pt "{self._font_family}";
|
||||
color: {self._text_description_color};
|
||||
padding-left: {self._padding}px;
|
||||
padding-right: {self._padding}px;
|
||||
}}
|
||||
"""
|
||||
|
||||
# BG FRAME
|
||||
self.bg_frame = QFrame()
|
||||
self.bg_frame.setObjectName("bg_frame")
|
||||
self.bg_frame.setStyleSheet(style)
|
||||
|
||||
# ADD TO LAYOUT
|
||||
self.widget_layout.addWidget(self.bg_frame)
|
||||
|
||||
# ADD BG LAYOUT
|
||||
self.bg_layout = QHBoxLayout(self.bg_frame)
|
||||
self.bg_layout.setContentsMargins(0,0,0,0)
|
||||
|
||||
# ADD COPYRIGHT TEXT
|
||||
self.copyright_label = QLabel(self._copyright)
|
||||
self.copyright_label.setAlignment(Qt.AlignVCenter)
|
||||
|
||||
# ADD VERSION TEXT
|
||||
self.version_label = QLabel(self._version)
|
||||
self.version_label.setAlignment(Qt.AlignVCenter)
|
||||
|
||||
# SEPARATOR
|
||||
self.separator = QSpacerItem(20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
|
||||
|
||||
# ADD TO LAYOUT
|
||||
self.bg_layout.addWidget(self.copyright_label)
|
||||
self.bg_layout.addSpacerItem(self.separator)
|
||||
self.bg_layout.addWidget(self.version_label)
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# PY CREDITS BAR AND VERSION
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyCredits(QWidget):
|
||||
def __init__(
|
||||
self,
|
||||
copyright,
|
||||
version,
|
||||
bg_two,
|
||||
font_family,
|
||||
text_size,
|
||||
text_description_color,
|
||||
radius = 8,
|
||||
padding = 10
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
# PROPERTIES
|
||||
self._copyright = copyright
|
||||
self._version = version
|
||||
self._bg_two = bg_two
|
||||
self._font_family = font_family
|
||||
self._text_size = text_size
|
||||
self._text_description_color = text_description_color
|
||||
self._radius = radius
|
||||
self._padding = padding
|
||||
|
||||
# SETUP UI
|
||||
self.setup_ui()
|
||||
|
||||
def setup_ui(self):
|
||||
# ADD LAYOUT
|
||||
self.widget_layout = QHBoxLayout(self)
|
||||
self.widget_layout.setContentsMargins(0,0,0,0)
|
||||
|
||||
# BG STYLE
|
||||
style = f"""
|
||||
#bg_frame {{
|
||||
border-radius: {self._radius}px;
|
||||
background-color: {self._bg_two};
|
||||
}}
|
||||
.QLabel {{
|
||||
font: {self._text_size}pt "{self._font_family}";
|
||||
color: {self._text_description_color};
|
||||
padding-left: {self._padding}px;
|
||||
padding-right: {self._padding}px;
|
||||
}}
|
||||
"""
|
||||
|
||||
# BG FRAME
|
||||
self.bg_frame = QFrame()
|
||||
self.bg_frame.setObjectName("bg_frame")
|
||||
self.bg_frame.setStyleSheet(style)
|
||||
|
||||
# ADD TO LAYOUT
|
||||
self.widget_layout.addWidget(self.bg_frame)
|
||||
|
||||
# ADD BG LAYOUT
|
||||
self.bg_layout = QHBoxLayout(self.bg_frame)
|
||||
self.bg_layout.setContentsMargins(0,0,0,0)
|
||||
|
||||
# ADD COPYRIGHT TEXT
|
||||
self.copyright_label = QLabel(self._copyright)
|
||||
self.copyright_label.setAlignment(Qt.AlignVCenter)
|
||||
|
||||
# ADD VERSION TEXT
|
||||
self.version_label = QLabel(self._version)
|
||||
self.version_label.setAlignment(Qt.AlignVCenter)
|
||||
|
||||
# SEPARATOR
|
||||
self.separator = QSpacerItem(20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
|
||||
|
||||
# ADD TO LAYOUT
|
||||
self.bg_layout.addWidget(self.copyright_label)
|
||||
self.bg_layout.addSpacerItem(self.separator)
|
||||
self.bg_layout.addWidget(self.version_label)
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
from . py_grips import PyGrips
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
from . py_grips import PyGrips
|
||||
|
||||
+249
-249
@@ -1,249 +1,249 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT PACKAGES AND MODULES
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
import sys
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# PY GRIPS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyGrips(QWidget):
|
||||
def __init__(self, parent, position, disable_color = False):
|
||||
|
||||
# SETUP UI
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
super().__init__()
|
||||
self.parent = parent
|
||||
self.setParent(parent)
|
||||
self.wi = Widgets()
|
||||
|
||||
# SHOW TOP LEFT GRIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
if position == "top_left":
|
||||
self.wi.top_left(self)
|
||||
grip = QSizeGrip(self.wi.top_left_grip)
|
||||
grip.setFixedSize(self.wi.top_left_grip.size())
|
||||
self.setGeometry(5, 5, 15, 15)
|
||||
|
||||
# ENABLE COLOR
|
||||
if disable_color:
|
||||
self.wi.top_left_grip.setStyleSheet("background: transparent")
|
||||
|
||||
# SHOW TOP RIGHT GRIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
if position == "top_right":
|
||||
self.wi.top_right(self)
|
||||
grip = QSizeGrip(self.wi.top_right_grip)
|
||||
grip.setFixedSize(self.wi.top_right_grip.size())
|
||||
self.setGeometry(self.parent.width() - 20, 5, 15, 15)
|
||||
|
||||
# ENABLE COLOR
|
||||
if disable_color:
|
||||
self.wi.top_right_grip.setStyleSheet("background: transparent")
|
||||
|
||||
# SHOW BOTTOM LEFT GRIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
if position == "bottom_left":
|
||||
self.wi.bottom_left(self)
|
||||
grip = QSizeGrip(self.wi.bottom_left_grip)
|
||||
grip.setFixedSize(self.wi.bottom_left_grip.size())
|
||||
self.setGeometry(5, self.parent.height() - 20, 15, 15)
|
||||
|
||||
# ENABLE COLOR
|
||||
if disable_color:
|
||||
self.wi.bottom_left_grip.setStyleSheet("background: transparent")
|
||||
|
||||
# SHOW BOTTOM RIGHT GRIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
if position == "bottom_right":
|
||||
self.wi.bottom_right(self)
|
||||
grip = QSizeGrip(self.wi.bottom_right_grip)
|
||||
grip.setFixedSize(self.wi.bottom_right_grip.size())
|
||||
self.setGeometry(self.parent.width() - 20, self.parent.height() - 20, 15, 15)
|
||||
|
||||
# ENABLE COLOR
|
||||
if disable_color:
|
||||
self.wi.bottom_right_grip.setStyleSheet("background: transparent")
|
||||
|
||||
# SHOW TOP GRIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
if position == "top":
|
||||
self.wi.top(self)
|
||||
self.setGeometry(0, 5, self.parent.width(), 10)
|
||||
self.setMaximumHeight(10)
|
||||
|
||||
# RESIZE TOP
|
||||
def resize_top(event):
|
||||
delta = event.pos()
|
||||
height = max(self.parent.minimumHeight(), self.parent.height() - delta.y())
|
||||
geo = self.parent.geometry()
|
||||
geo.setTop(geo.bottom() - height)
|
||||
self.parent.setGeometry(geo)
|
||||
event.accept()
|
||||
self.wi.top_grip.mouseMoveEvent = resize_top
|
||||
|
||||
# ENABLE COLOR
|
||||
if disable_color:
|
||||
self.wi.top_grip.setStyleSheet("background: transparent")
|
||||
|
||||
# SHOW BOTTOM GRIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
elif position == "bottom":
|
||||
self.wi.bottom(self)
|
||||
self.setGeometry(0, self.parent.height() - 10, self.parent.width(), 10)
|
||||
self.setMaximumHeight(10)
|
||||
|
||||
# RESIZE BOTTOM
|
||||
def resize_bottom(event):
|
||||
delta = event.pos()
|
||||
height = max(self.parent.minimumHeight(), self.parent.height() + delta.y())
|
||||
self.parent.resize(self.parent.width(), height)
|
||||
event.accept()
|
||||
self.wi.bottom_grip.mouseMoveEvent = resize_bottom
|
||||
|
||||
# ENABLE COLOR
|
||||
if disable_color:
|
||||
self.wi.bottom_grip.setStyleSheet("background: transparent")
|
||||
|
||||
# SHOW LEFT GRIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
elif position == "left":
|
||||
self.wi.left(self)
|
||||
self.setGeometry(0, 10, 10, self.parent.height())
|
||||
self.setMaximumWidth(10)
|
||||
|
||||
# RESIZE LEFT
|
||||
def resize_left(event):
|
||||
delta = event.pos()
|
||||
width = max(self.parent.minimumWidth(), self.parent.width() - delta.x())
|
||||
geo = self.parent.geometry()
|
||||
geo.setLeft(geo.right() - width)
|
||||
self.parent.setGeometry(geo)
|
||||
event.accept()
|
||||
self.wi.left_grip.mouseMoveEvent = resize_left
|
||||
|
||||
# ENABLE COLOR
|
||||
if disable_color:
|
||||
self.wi.left_grip.setStyleSheet("background: transparent")
|
||||
|
||||
# RESIZE RIGHT
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
elif position == "right":
|
||||
self.wi.right(self)
|
||||
self.setGeometry(self.parent.width() - 10, 10, 10, self.parent.height())
|
||||
self.setMaximumWidth(10)
|
||||
|
||||
def resize_right(event):
|
||||
delta = event.pos()
|
||||
width = max(self.parent.minimumWidth(), self.parent.width() + delta.x())
|
||||
self.parent.resize(width, self.parent.height())
|
||||
event.accept()
|
||||
self.wi.right_grip.mouseMoveEvent = resize_right
|
||||
|
||||
# ENABLE COLOR
|
||||
if disable_color:
|
||||
self.wi.right_grip.setStyleSheet("background: transparent")
|
||||
|
||||
# MOUSE RELEASE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def mouseReleaseEvent(self, event):
|
||||
self.mousePos = None
|
||||
|
||||
# RESIZE EVENT
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def resizeEvent(self, event):
|
||||
if hasattr(self.wi, 'top_grip'):
|
||||
self.wi.top_grip.setGeometry(0, 0, self.width(), 10)
|
||||
|
||||
elif hasattr(self.wi, 'bottom_grip'):
|
||||
self.wi.bottom_grip.setGeometry(0, 0, self.width(), 10)
|
||||
|
||||
elif hasattr(self.wi, 'left_grip'):
|
||||
self.wi.left_grip.setGeometry(0, 0, 10, self.height() - 20)
|
||||
|
||||
elif hasattr(self.wi, 'right_grip'):
|
||||
self.wi.right_grip.setGeometry(0, 0, 10, self.height() - 20)
|
||||
|
||||
elif hasattr(self.wi, 'top_right_grip'):
|
||||
self.wi.top_right_grip.setGeometry(self.width() - 15, 0, 15, 15)
|
||||
|
||||
elif hasattr(self.wi, 'bottom_left_grip'):
|
||||
self.wi.bottom_left_grip.setGeometry(0, self.height() - 15, 15, 15)
|
||||
|
||||
elif hasattr(self.wi, 'bottom_right_grip'):
|
||||
self.wi.bottom_right_grip.setGeometry(self.width() - 15, self.height() - 15, 15, 15)
|
||||
|
||||
|
||||
# GRIP WIDGTES
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class Widgets(object):
|
||||
def top_left(self, form):
|
||||
self.top_left_grip = QFrame(form)
|
||||
self.top_left_grip.setObjectName(u"top_left_grip")
|
||||
self.top_left_grip.setFixedSize(15, 15)
|
||||
self.top_left_grip.setStyleSheet(u"background-color: #333; border: 2px solid #55FF00;")
|
||||
|
||||
def top_right(self, form):
|
||||
self.top_right_grip = QFrame(form)
|
||||
self.top_right_grip.setObjectName(u"top_right_grip")
|
||||
self.top_right_grip.setFixedSize(15, 15)
|
||||
self.top_right_grip.setStyleSheet(u"background-color: #333; border: 2px solid #55FF00;")
|
||||
|
||||
def bottom_left(self, form):
|
||||
self.bottom_left_grip = QFrame(form)
|
||||
self.bottom_left_grip.setObjectName(u"bottom_left_grip")
|
||||
self.bottom_left_grip.setFixedSize(15, 15)
|
||||
self.bottom_left_grip.setStyleSheet(u"background-color: #333; border: 2px solid #55FF00;")
|
||||
|
||||
def bottom_right(self, form):
|
||||
self.bottom_right_grip = QFrame(form)
|
||||
self.bottom_right_grip.setObjectName(u"bottom_right_grip")
|
||||
self.bottom_right_grip.setFixedSize(15, 15)
|
||||
self.bottom_right_grip.setStyleSheet(u"background-color: #333; border: 2px solid #55FF00;")
|
||||
|
||||
def top(self, form):
|
||||
self.top_grip = QFrame(form)
|
||||
self.top_grip.setObjectName(u"top_grip")
|
||||
self.top_grip.setGeometry(QRect(0, 0, 500, 10))
|
||||
self.top_grip.setStyleSheet(u"background-color: rgb(85, 255, 255);")
|
||||
self.top_grip.setCursor(QCursor(Qt.SizeVerCursor))
|
||||
|
||||
def bottom(self, form):
|
||||
self.bottom_grip = QFrame(form)
|
||||
self.bottom_grip.setObjectName(u"bottom_grip")
|
||||
self.bottom_grip.setGeometry(QRect(0, 0, 500, 10))
|
||||
self.bottom_grip.setStyleSheet(u"background-color: rgb(85, 170, 0);")
|
||||
self.bottom_grip.setCursor(QCursor(Qt.SizeVerCursor))
|
||||
|
||||
def left(self, form):
|
||||
self.left_grip = QFrame(form)
|
||||
self.left_grip.setObjectName(u"left")
|
||||
self.left_grip.setGeometry(QRect(0, 10, 10, 480))
|
||||
self.left_grip.setMinimumSize(QSize(10, 0))
|
||||
self.left_grip.setCursor(QCursor(Qt.SizeHorCursor))
|
||||
self.left_grip.setStyleSheet(u"background-color: rgb(255, 121, 198);")
|
||||
|
||||
def right(self, form):
|
||||
self.right_grip = QFrame(form)
|
||||
self.right_grip.setObjectName(u"right")
|
||||
self.right_grip.setGeometry(QRect(0, 0, 10, 500))
|
||||
self.right_grip.setMinimumSize(QSize(10, 0))
|
||||
self.right_grip.setCursor(QCursor(Qt.SizeHorCursor))
|
||||
self.right_grip.setStyleSheet(u"background-color: rgb(255, 0, 127);")
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT PACKAGES AND MODULES
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
import sys
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# PY GRIPS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyGrips(QWidget):
|
||||
def __init__(self, parent, position, disable_color = False):
|
||||
|
||||
# SETUP UI
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
super().__init__()
|
||||
self.parent = parent
|
||||
self.setParent(parent)
|
||||
self.wi = Widgets()
|
||||
|
||||
# SHOW TOP LEFT GRIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
if position == "top_left":
|
||||
self.wi.top_left(self)
|
||||
grip = QSizeGrip(self.wi.top_left_grip)
|
||||
grip.setFixedSize(self.wi.top_left_grip.size())
|
||||
self.setGeometry(5, 5, 15, 15)
|
||||
|
||||
# ENABLE COLOR
|
||||
if disable_color:
|
||||
self.wi.top_left_grip.setStyleSheet("background: transparent")
|
||||
|
||||
# SHOW TOP RIGHT GRIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
if position == "top_right":
|
||||
self.wi.top_right(self)
|
||||
grip = QSizeGrip(self.wi.top_right_grip)
|
||||
grip.setFixedSize(self.wi.top_right_grip.size())
|
||||
self.setGeometry(self.parent.width() - 20, 5, 15, 15)
|
||||
|
||||
# ENABLE COLOR
|
||||
if disable_color:
|
||||
self.wi.top_right_grip.setStyleSheet("background: transparent")
|
||||
|
||||
# SHOW BOTTOM LEFT GRIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
if position == "bottom_left":
|
||||
self.wi.bottom_left(self)
|
||||
grip = QSizeGrip(self.wi.bottom_left_grip)
|
||||
grip.setFixedSize(self.wi.bottom_left_grip.size())
|
||||
self.setGeometry(5, self.parent.height() - 20, 15, 15)
|
||||
|
||||
# ENABLE COLOR
|
||||
if disable_color:
|
||||
self.wi.bottom_left_grip.setStyleSheet("background: transparent")
|
||||
|
||||
# SHOW BOTTOM RIGHT GRIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
if position == "bottom_right":
|
||||
self.wi.bottom_right(self)
|
||||
grip = QSizeGrip(self.wi.bottom_right_grip)
|
||||
grip.setFixedSize(self.wi.bottom_right_grip.size())
|
||||
self.setGeometry(self.parent.width() - 20, self.parent.height() - 20, 15, 15)
|
||||
|
||||
# ENABLE COLOR
|
||||
if disable_color:
|
||||
self.wi.bottom_right_grip.setStyleSheet("background: transparent")
|
||||
|
||||
# SHOW TOP GRIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
if position == "top":
|
||||
self.wi.top(self)
|
||||
self.setGeometry(0, 5, self.parent.width(), 10)
|
||||
self.setMaximumHeight(10)
|
||||
|
||||
# RESIZE TOP
|
||||
def resize_top(event):
|
||||
delta = event.pos()
|
||||
height = max(self.parent.minimumHeight(), self.parent.height() - delta.y())
|
||||
geo = self.parent.geometry()
|
||||
geo.setTop(geo.bottom() - height)
|
||||
self.parent.setGeometry(geo)
|
||||
event.accept()
|
||||
self.wi.top_grip.mouseMoveEvent = resize_top
|
||||
|
||||
# ENABLE COLOR
|
||||
if disable_color:
|
||||
self.wi.top_grip.setStyleSheet("background: transparent")
|
||||
|
||||
# SHOW BOTTOM GRIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
elif position == "bottom":
|
||||
self.wi.bottom(self)
|
||||
self.setGeometry(0, self.parent.height() - 10, self.parent.width(), 10)
|
||||
self.setMaximumHeight(10)
|
||||
|
||||
# RESIZE BOTTOM
|
||||
def resize_bottom(event):
|
||||
delta = event.pos()
|
||||
height = max(self.parent.minimumHeight(), self.parent.height() + delta.y())
|
||||
self.parent.resize(self.parent.width(), height)
|
||||
event.accept()
|
||||
self.wi.bottom_grip.mouseMoveEvent = resize_bottom
|
||||
|
||||
# ENABLE COLOR
|
||||
if disable_color:
|
||||
self.wi.bottom_grip.setStyleSheet("background: transparent")
|
||||
|
||||
# SHOW LEFT GRIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
elif position == "left":
|
||||
self.wi.left(self)
|
||||
self.setGeometry(0, 10, 10, self.parent.height())
|
||||
self.setMaximumWidth(10)
|
||||
|
||||
# RESIZE LEFT
|
||||
def resize_left(event):
|
||||
delta = event.pos()
|
||||
width = max(self.parent.minimumWidth(), self.parent.width() - delta.x())
|
||||
geo = self.parent.geometry()
|
||||
geo.setLeft(geo.right() - width)
|
||||
self.parent.setGeometry(geo)
|
||||
event.accept()
|
||||
self.wi.left_grip.mouseMoveEvent = resize_left
|
||||
|
||||
# ENABLE COLOR
|
||||
if disable_color:
|
||||
self.wi.left_grip.setStyleSheet("background: transparent")
|
||||
|
||||
# RESIZE RIGHT
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
elif position == "right":
|
||||
self.wi.right(self)
|
||||
self.setGeometry(self.parent.width() - 10, 10, 10, self.parent.height())
|
||||
self.setMaximumWidth(10)
|
||||
|
||||
def resize_right(event):
|
||||
delta = event.pos()
|
||||
width = max(self.parent.minimumWidth(), self.parent.width() + delta.x())
|
||||
self.parent.resize(width, self.parent.height())
|
||||
event.accept()
|
||||
self.wi.right_grip.mouseMoveEvent = resize_right
|
||||
|
||||
# ENABLE COLOR
|
||||
if disable_color:
|
||||
self.wi.right_grip.setStyleSheet("background: transparent")
|
||||
|
||||
# MOUSE RELEASE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def mouseReleaseEvent(self, event):
|
||||
self.mousePos = None
|
||||
|
||||
# RESIZE EVENT
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def resizeEvent(self, event):
|
||||
if hasattr(self.wi, 'top_grip'):
|
||||
self.wi.top_grip.setGeometry(0, 0, self.width(), 10)
|
||||
|
||||
elif hasattr(self.wi, 'bottom_grip'):
|
||||
self.wi.bottom_grip.setGeometry(0, 0, self.width(), 10)
|
||||
|
||||
elif hasattr(self.wi, 'left_grip'):
|
||||
self.wi.left_grip.setGeometry(0, 0, 10, self.height() - 20)
|
||||
|
||||
elif hasattr(self.wi, 'right_grip'):
|
||||
self.wi.right_grip.setGeometry(0, 0, 10, self.height() - 20)
|
||||
|
||||
elif hasattr(self.wi, 'top_right_grip'):
|
||||
self.wi.top_right_grip.setGeometry(self.width() - 15, 0, 15, 15)
|
||||
|
||||
elif hasattr(self.wi, 'bottom_left_grip'):
|
||||
self.wi.bottom_left_grip.setGeometry(0, self.height() - 15, 15, 15)
|
||||
|
||||
elif hasattr(self.wi, 'bottom_right_grip'):
|
||||
self.wi.bottom_right_grip.setGeometry(self.width() - 15, self.height() - 15, 15, 15)
|
||||
|
||||
|
||||
# GRIP WIDGTES
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class Widgets(object):
|
||||
def top_left(self, form):
|
||||
self.top_left_grip = QFrame(form)
|
||||
self.top_left_grip.setObjectName(u"top_left_grip")
|
||||
self.top_left_grip.setFixedSize(15, 15)
|
||||
self.top_left_grip.setStyleSheet(u"background-color: #333; border: 2px solid #55FF00;")
|
||||
|
||||
def top_right(self, form):
|
||||
self.top_right_grip = QFrame(form)
|
||||
self.top_right_grip.setObjectName(u"top_right_grip")
|
||||
self.top_right_grip.setFixedSize(15, 15)
|
||||
self.top_right_grip.setStyleSheet(u"background-color: #333; border: 2px solid #55FF00;")
|
||||
|
||||
def bottom_left(self, form):
|
||||
self.bottom_left_grip = QFrame(form)
|
||||
self.bottom_left_grip.setObjectName(u"bottom_left_grip")
|
||||
self.bottom_left_grip.setFixedSize(15, 15)
|
||||
self.bottom_left_grip.setStyleSheet(u"background-color: #333; border: 2px solid #55FF00;")
|
||||
|
||||
def bottom_right(self, form):
|
||||
self.bottom_right_grip = QFrame(form)
|
||||
self.bottom_right_grip.setObjectName(u"bottom_right_grip")
|
||||
self.bottom_right_grip.setFixedSize(15, 15)
|
||||
self.bottom_right_grip.setStyleSheet(u"background-color: #333; border: 2px solid #55FF00;")
|
||||
|
||||
def top(self, form):
|
||||
self.top_grip = QFrame(form)
|
||||
self.top_grip.setObjectName(u"top_grip")
|
||||
self.top_grip.setGeometry(QRect(0, 0, 500, 10))
|
||||
self.top_grip.setStyleSheet(u"background-color: rgb(85, 255, 255);")
|
||||
self.top_grip.setCursor(QCursor(Qt.SizeVerCursor))
|
||||
|
||||
def bottom(self, form):
|
||||
self.bottom_grip = QFrame(form)
|
||||
self.bottom_grip.setObjectName(u"bottom_grip")
|
||||
self.bottom_grip.setGeometry(QRect(0, 0, 500, 10))
|
||||
self.bottom_grip.setStyleSheet(u"background-color: rgb(85, 170, 0);")
|
||||
self.bottom_grip.setCursor(QCursor(Qt.SizeVerCursor))
|
||||
|
||||
def left(self, form):
|
||||
self.left_grip = QFrame(form)
|
||||
self.left_grip.setObjectName(u"left")
|
||||
self.left_grip.setGeometry(QRect(0, 10, 10, 480))
|
||||
self.left_grip.setMinimumSize(QSize(10, 0))
|
||||
self.left_grip.setCursor(QCursor(Qt.SizeHorCursor))
|
||||
self.left_grip.setStyleSheet(u"background-color: rgb(255, 121, 198);")
|
||||
|
||||
def right(self, form):
|
||||
self.right_grip = QFrame(form)
|
||||
self.right_grip.setObjectName(u"right")
|
||||
self.right_grip.setGeometry(QRect(0, 0, 10, 500))
|
||||
self.right_grip.setMinimumSize(QSize(10, 0))
|
||||
self.right_grip.setCursor(QCursor(Qt.SizeHorCursor))
|
||||
self.right_grip.setStyleSheet(u"background-color: rgb(255, 0, 127);")
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# PY ICON BUTTON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# PY ICON BUTTON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_icon_button import PyIconButton
|
||||
@@ -1,268 +1,268 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# PY TITLE BUTTON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyIconButton(QPushButton):
|
||||
def __init__(
|
||||
self,
|
||||
icon_path = None,
|
||||
parent = None,
|
||||
app_parent = None,
|
||||
tooltip_text = "",
|
||||
btn_id = None,
|
||||
width = 30,
|
||||
height = 30,
|
||||
radius = 8,
|
||||
bg_color = "#343b48",
|
||||
bg_color_hover = "#3c4454",
|
||||
bg_color_pressed = "#2c313c",
|
||||
icon_color = "#c3ccdf",
|
||||
icon_color_hover = "#dce1ec",
|
||||
icon_color_pressed = "#edf0f5",
|
||||
icon_color_active = "#f5f6f9",
|
||||
dark_one = "#1b1e23",
|
||||
text_foreground = "#8a95aa",
|
||||
context_color = "#568af2",
|
||||
top_margin = 40,
|
||||
is_active = False
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
# SET DEFAULT PARAMETERS
|
||||
self.setFixedSize(width, height)
|
||||
self.setCursor(Qt.PointingHandCursor)
|
||||
self.setObjectName(btn_id)
|
||||
|
||||
# PROPERTIES
|
||||
self._bg_color = bg_color
|
||||
self._bg_color_hover = bg_color_hover
|
||||
self._bg_color_pressed = bg_color_pressed
|
||||
self._icon_color = icon_color
|
||||
self._icon_color_hover = icon_color_hover
|
||||
self._icon_color_pressed = icon_color_pressed
|
||||
self._icon_color_active = icon_color_active
|
||||
self._context_color = context_color
|
||||
self._top_margin = top_margin
|
||||
self._is_active = is_active
|
||||
# Set Parameters
|
||||
self._set_bg_color = bg_color
|
||||
self._set_icon_path = icon_path
|
||||
self._set_icon_color = icon_color
|
||||
self._set_border_radius = radius
|
||||
# Parent
|
||||
self._parent = parent
|
||||
self._app_parent = app_parent
|
||||
|
||||
# TOOLTIP
|
||||
self._tooltip_text = tooltip_text
|
||||
self._tooltip = _ToolTip(
|
||||
app_parent,
|
||||
tooltip_text,
|
||||
dark_one,
|
||||
text_foreground
|
||||
)
|
||||
self._tooltip.hide()
|
||||
|
||||
# SET ACTIVE MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def set_active(self, is_active):
|
||||
self._is_active = is_active
|
||||
self.repaint()
|
||||
|
||||
# RETURN IF IS ACTIVE MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def is_active(self):
|
||||
return self._is_active
|
||||
|
||||
# PAINT EVENT
|
||||
# painting the button and the icon
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def paintEvent(self, event):
|
||||
# PAINTER
|
||||
paint = QPainter()
|
||||
paint.begin(self)
|
||||
paint.setRenderHint(QPainter.RenderHint.Antialiasing)
|
||||
|
||||
if self._is_active:
|
||||
# BRUSH
|
||||
brush = QBrush(QColor(self._context_color))
|
||||
else:
|
||||
# BRUSH
|
||||
brush = QBrush(QColor(self._set_bg_color))
|
||||
|
||||
# CREATE RECTANGLE
|
||||
rect = QRect(0, 0, self.width(), self.height())
|
||||
paint.setPen(Qt.NoPen)
|
||||
paint.setBrush(brush)
|
||||
paint.drawRoundedRect(
|
||||
rect,
|
||||
self._set_border_radius,
|
||||
self._set_border_radius
|
||||
)
|
||||
|
||||
# DRAW ICONS
|
||||
self.icon_paint(paint, self._set_icon_path, rect)
|
||||
|
||||
# END PAINTER
|
||||
paint.end()
|
||||
|
||||
# CHANGE STYLES
|
||||
# Functions with custom styles
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def change_style(self, event):
|
||||
if event == QEvent.Enter:
|
||||
self._set_bg_color = self._bg_color_hover
|
||||
self._set_icon_color = self._icon_color_hover
|
||||
self.repaint()
|
||||
elif event == QEvent.Leave:
|
||||
self._set_bg_color = self._bg_color
|
||||
self._set_icon_color = self._icon_color
|
||||
self.repaint()
|
||||
elif event == QEvent.MouseButtonPress:
|
||||
self._set_bg_color = self._bg_color_pressed
|
||||
self._set_icon_color = self._icon_color_pressed
|
||||
self.repaint()
|
||||
elif event == QEvent.MouseButtonRelease:
|
||||
self._set_bg_color = self._bg_color_hover
|
||||
self._set_icon_color = self._icon_color_hover
|
||||
self.repaint()
|
||||
|
||||
# MOUSE OVER
|
||||
# Event triggered when the mouse is over the BTN
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def enterEvent(self, event):
|
||||
self.change_style(QEvent.Enter)
|
||||
self.move_tooltip()
|
||||
self._tooltip.show()
|
||||
|
||||
# MOUSE LEAVE
|
||||
# Event fired when the mouse leaves the BTN
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def leaveEvent(self, event):
|
||||
self.change_style(QEvent.Leave)
|
||||
self.move_tooltip()
|
||||
self._tooltip.hide()
|
||||
|
||||
# MOUSE PRESS
|
||||
# Event triggered when the left button is pressed
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def mousePressEvent(self, event):
|
||||
if event.button() == Qt.LeftButton:
|
||||
self.change_style(QEvent.MouseButtonPress)
|
||||
# SET FOCUS
|
||||
self.setFocus()
|
||||
# EMIT SIGNAL
|
||||
return self.clicked.emit()
|
||||
|
||||
# MOUSE RELEASED
|
||||
# Event triggered after the mouse button is released
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def mouseReleaseEvent(self, event):
|
||||
if event.button() == Qt.LeftButton:
|
||||
self.change_style(QEvent.MouseButtonRelease)
|
||||
# EMIT SIGNAL
|
||||
return self.released.emit()
|
||||
|
||||
# DRAW ICON WITH COLORS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def icon_paint(self, qp, image, rect):
|
||||
icon = QPixmap(image)
|
||||
painter = QPainter(icon)
|
||||
painter.setCompositionMode(QPainter.CompositionMode_SourceIn)
|
||||
if self._is_active:
|
||||
painter.fillRect(icon.rect(), self._icon_color_active)
|
||||
else:
|
||||
painter.fillRect(icon.rect(), self._set_icon_color)
|
||||
qp.drawPixmap(
|
||||
(rect.width() - icon.width()) / 2,
|
||||
(rect.height() - icon.height()) / 2,
|
||||
icon
|
||||
)
|
||||
painter.end()
|
||||
|
||||
# SET ICON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def set_icon(self, icon_path):
|
||||
self._set_icon_path = icon_path
|
||||
self.repaint()
|
||||
|
||||
# MOVE TOOLTIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def move_tooltip(self):
|
||||
# GET MAIN WINDOW PARENT
|
||||
gp = self.mapToGlobal(QPoint(0, 0))
|
||||
|
||||
# SET WIDGET TO GET POSTION
|
||||
# Return absolute position of widget inside app
|
||||
pos = self._parent.mapFromGlobal(gp)
|
||||
|
||||
# FORMAT POSITION
|
||||
# Adjust tooltip position with offset
|
||||
pos_x = (pos.x() - (self._tooltip.width() // 2)) + (self.width() // 2)
|
||||
pos_y = pos.y() - self._top_margin
|
||||
|
||||
# SET POSITION TO WIDGET
|
||||
# Move tooltip position
|
||||
self._tooltip.move(pos_x, pos_y)
|
||||
|
||||
# TOOLTIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class _ToolTip(QLabel):
|
||||
# TOOLTIP / LABEL StyleSheet
|
||||
style_tooltip = """
|
||||
QLabel {{
|
||||
background-color: {_dark_one};
|
||||
color: {_text_foreground};
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
border-radius: 17px;
|
||||
border: 0px solid transparent;
|
||||
font: 800 9pt "Segoe UI";
|
||||
}}
|
||||
"""
|
||||
def __init__(
|
||||
self,
|
||||
parent,
|
||||
tooltip,
|
||||
dark_one,
|
||||
text_foreground
|
||||
):
|
||||
QLabel.__init__(self)
|
||||
|
||||
# LABEL SETUP
|
||||
style = self.style_tooltip.format(
|
||||
_dark_one = dark_one,
|
||||
_text_foreground = text_foreground
|
||||
)
|
||||
self.setObjectName(u"label_tooltip")
|
||||
self.setStyleSheet(style)
|
||||
self.setMinimumHeight(34)
|
||||
self.setParent(parent)
|
||||
self.setText(tooltip)
|
||||
self.adjustSize()
|
||||
|
||||
# SET DROP SHADOW
|
||||
self.shadow = QGraphicsDropShadowEffect(self)
|
||||
self.shadow.setBlurRadius(30)
|
||||
self.shadow.setXOffset(0)
|
||||
self.shadow.setYOffset(0)
|
||||
self.shadow.setColor(QColor(0, 0, 0, 80))
|
||||
self.setGraphicsEffect(self.shadow)
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# PY TITLE BUTTON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyIconButton(QPushButton):
|
||||
def __init__(
|
||||
self,
|
||||
icon_path = None,
|
||||
parent = None,
|
||||
app_parent = None,
|
||||
tooltip_text = "",
|
||||
btn_id = None,
|
||||
width = 30,
|
||||
height = 30,
|
||||
radius = 8,
|
||||
bg_color = "#343b48",
|
||||
bg_color_hover = "#3c4454",
|
||||
bg_color_pressed = "#2c313c",
|
||||
icon_color = "#c3ccdf",
|
||||
icon_color_hover = "#dce1ec",
|
||||
icon_color_pressed = "#edf0f5",
|
||||
icon_color_active = "#f5f6f9",
|
||||
dark_one = "#1b1e23",
|
||||
text_foreground = "#8a95aa",
|
||||
context_color = "#568af2",
|
||||
top_margin = 40,
|
||||
is_active = False
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
# SET DEFAULT PARAMETERS
|
||||
self.setFixedSize(width, height)
|
||||
self.setCursor(Qt.PointingHandCursor)
|
||||
self.setObjectName(btn_id)
|
||||
|
||||
# PROPERTIES
|
||||
self._bg_color = bg_color
|
||||
self._bg_color_hover = bg_color_hover
|
||||
self._bg_color_pressed = bg_color_pressed
|
||||
self._icon_color = icon_color
|
||||
self._icon_color_hover = icon_color_hover
|
||||
self._icon_color_pressed = icon_color_pressed
|
||||
self._icon_color_active = icon_color_active
|
||||
self._context_color = context_color
|
||||
self._top_margin = top_margin
|
||||
self._is_active = is_active
|
||||
# Set Parameters
|
||||
self._set_bg_color = bg_color
|
||||
self._set_icon_path = icon_path
|
||||
self._set_icon_color = icon_color
|
||||
self._set_border_radius = radius
|
||||
# Parent
|
||||
self._parent = parent
|
||||
self._app_parent = app_parent
|
||||
|
||||
# TOOLTIP
|
||||
self._tooltip_text = tooltip_text
|
||||
self._tooltip = _ToolTip(
|
||||
app_parent,
|
||||
tooltip_text,
|
||||
dark_one,
|
||||
text_foreground
|
||||
)
|
||||
self._tooltip.hide()
|
||||
|
||||
# SET ACTIVE MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def set_active(self, is_active):
|
||||
self._is_active = is_active
|
||||
self.repaint()
|
||||
|
||||
# RETURN IF IS ACTIVE MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def is_active(self):
|
||||
return self._is_active
|
||||
|
||||
# PAINT EVENT
|
||||
# painting the button and the icon
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def paintEvent(self, event):
|
||||
# PAINTER
|
||||
paint = QPainter()
|
||||
paint.begin(self)
|
||||
paint.setRenderHint(QPainter.RenderHint.Antialiasing)
|
||||
|
||||
if self._is_active:
|
||||
# BRUSH
|
||||
brush = QBrush(QColor(self._context_color))
|
||||
else:
|
||||
# BRUSH
|
||||
brush = QBrush(QColor(self._set_bg_color))
|
||||
|
||||
# CREATE RECTANGLE
|
||||
rect = QRect(0, 0, self.width(), self.height())
|
||||
paint.setPen(Qt.NoPen)
|
||||
paint.setBrush(brush)
|
||||
paint.drawRoundedRect(
|
||||
rect,
|
||||
self._set_border_radius,
|
||||
self._set_border_radius
|
||||
)
|
||||
|
||||
# DRAW ICONS
|
||||
self.icon_paint(paint, self._set_icon_path, rect)
|
||||
|
||||
# END PAINTER
|
||||
paint.end()
|
||||
|
||||
# CHANGE STYLES
|
||||
# Functions with custom styles
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def change_style(self, event):
|
||||
if event == QEvent.Enter:
|
||||
self._set_bg_color = self._bg_color_hover
|
||||
self._set_icon_color = self._icon_color_hover
|
||||
self.repaint()
|
||||
elif event == QEvent.Leave:
|
||||
self._set_bg_color = self._bg_color
|
||||
self._set_icon_color = self._icon_color
|
||||
self.repaint()
|
||||
elif event == QEvent.MouseButtonPress:
|
||||
self._set_bg_color = self._bg_color_pressed
|
||||
self._set_icon_color = self._icon_color_pressed
|
||||
self.repaint()
|
||||
elif event == QEvent.MouseButtonRelease:
|
||||
self._set_bg_color = self._bg_color_hover
|
||||
self._set_icon_color = self._icon_color_hover
|
||||
self.repaint()
|
||||
|
||||
# MOUSE OVER
|
||||
# Event triggered when the mouse is over the BTN
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def enterEvent(self, event):
|
||||
self.change_style(QEvent.Enter)
|
||||
self.move_tooltip()
|
||||
self._tooltip.show()
|
||||
|
||||
# MOUSE LEAVE
|
||||
# Event fired when the mouse leaves the BTN
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def leaveEvent(self, event):
|
||||
self.change_style(QEvent.Leave)
|
||||
self.move_tooltip()
|
||||
self._tooltip.hide()
|
||||
|
||||
# MOUSE PRESS
|
||||
# Event triggered when the left button is pressed
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def mousePressEvent(self, event):
|
||||
if event.button() == Qt.LeftButton:
|
||||
self.change_style(QEvent.MouseButtonPress)
|
||||
# SET FOCUS
|
||||
self.setFocus()
|
||||
# EMIT SIGNAL
|
||||
return self.clicked.emit()
|
||||
|
||||
# MOUSE RELEASED
|
||||
# Event triggered after the mouse button is released
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def mouseReleaseEvent(self, event):
|
||||
if event.button() == Qt.LeftButton:
|
||||
self.change_style(QEvent.MouseButtonRelease)
|
||||
# EMIT SIGNAL
|
||||
return self.released.emit()
|
||||
|
||||
# DRAW ICON WITH COLORS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def icon_paint(self, qp, image, rect):
|
||||
icon = QPixmap(image)
|
||||
painter = QPainter(icon)
|
||||
painter.setCompositionMode(QPainter.CompositionMode_SourceIn)
|
||||
if self._is_active:
|
||||
painter.fillRect(icon.rect(), self._icon_color_active)
|
||||
else:
|
||||
painter.fillRect(icon.rect(), self._set_icon_color)
|
||||
qp.drawPixmap(
|
||||
(rect.width() - icon.width()) / 2,
|
||||
(rect.height() - icon.height()) / 2,
|
||||
icon
|
||||
)
|
||||
painter.end()
|
||||
|
||||
# SET ICON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def set_icon(self, icon_path):
|
||||
self._set_icon_path = icon_path
|
||||
self.repaint()
|
||||
|
||||
# MOVE TOOLTIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def move_tooltip(self):
|
||||
# GET MAIN WINDOW PARENT
|
||||
gp = self.mapToGlobal(QPoint(0, 0))
|
||||
|
||||
# SET WIDGET TO GET POSTION
|
||||
# Return absolute position of widget inside app
|
||||
pos = self._parent.mapFromGlobal(gp)
|
||||
|
||||
# FORMAT POSITION
|
||||
# Adjust tooltip position with offset
|
||||
pos_x = (pos.x() - (self._tooltip.width() // 2)) + (self.width() // 2)
|
||||
pos_y = pos.y() - self._top_margin
|
||||
|
||||
# SET POSITION TO WIDGET
|
||||
# Move tooltip position
|
||||
self._tooltip.move(pos_x, pos_y)
|
||||
|
||||
# TOOLTIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class _ToolTip(QLabel):
|
||||
# TOOLTIP / LABEL StyleSheet
|
||||
style_tooltip = """
|
||||
QLabel {{
|
||||
background-color: {_dark_one};
|
||||
color: {_text_foreground};
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
border-radius: 17px;
|
||||
border: 0px solid transparent;
|
||||
font: 800 9pt "Segoe UI";
|
||||
}}
|
||||
"""
|
||||
def __init__(
|
||||
self,
|
||||
parent,
|
||||
tooltip,
|
||||
dark_one,
|
||||
text_foreground
|
||||
):
|
||||
QLabel.__init__(self)
|
||||
|
||||
# LABEL SETUP
|
||||
style = self.style_tooltip.format(
|
||||
_dark_one = dark_one,
|
||||
_text_foreground = text_foreground
|
||||
)
|
||||
self.setObjectName(u"label_tooltip")
|
||||
self.setStyleSheet(style)
|
||||
self.setMinimumHeight(34)
|
||||
self.setParent(parent)
|
||||
self.setText(tooltip)
|
||||
self.adjustSize()
|
||||
|
||||
# SET DROP SHADOW
|
||||
self.shadow = QGraphicsDropShadowEffect(self)
|
||||
self.shadow.setBlurRadius(30)
|
||||
self.shadow.setXOffset(0)
|
||||
self.shadow.setYOffset(0)
|
||||
self.shadow.setColor(QColor(0, 0, 0, 80))
|
||||
self.setGraphicsEffect(self.shadow)
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# PY LEFT COLUMN
|
||||
# Left column with custom widgets
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# PY LEFT COLUMN
|
||||
# Left column with custom widgets
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_left_column import PyLeftColumn
|
||||
@@ -1,70 +1,70 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# PY ICON WITH CUSTOM COLORS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyIcon(QWidget):
|
||||
def __init__(
|
||||
self,
|
||||
icon_path,
|
||||
icon_color
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
# PROPERTIES
|
||||
self._icon_path = icon_path
|
||||
self._icon_color = icon_color
|
||||
|
||||
# SETUP UI
|
||||
self.setup_ui()
|
||||
|
||||
def setup_ui(self):
|
||||
# LAYOUT
|
||||
self.layout = QVBoxLayout(self)
|
||||
self.layout.setContentsMargins(0,0,0,0)
|
||||
|
||||
# LABEL
|
||||
self.icon = QLabel()
|
||||
self.icon.setAlignment(Qt.AlignCenter)
|
||||
|
||||
# PAINTER
|
||||
self.set_icon(self._icon_path, self._icon_color)
|
||||
|
||||
# ADD TO LAYOUT
|
||||
self.layout.addWidget(self.icon)
|
||||
|
||||
def set_icon(self, icon_path, icon_color = None):
|
||||
# GET COLOR
|
||||
color = ""
|
||||
if icon_color != None:
|
||||
color = icon_color
|
||||
else:
|
||||
color = self._icon_color
|
||||
|
||||
# PAINTER / PIXMAP
|
||||
icon = QPixmap(icon_path)
|
||||
painter = QPainter(icon)
|
||||
painter.setCompositionMode(QPainter.CompositionMode_SourceIn)
|
||||
painter.fillRect(icon.rect(), color)
|
||||
painter.end()
|
||||
|
||||
# SET PIXMAP
|
||||
self.icon.setPixmap(icon)
|
||||
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# PY ICON WITH CUSTOM COLORS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyIcon(QWidget):
|
||||
def __init__(
|
||||
self,
|
||||
icon_path,
|
||||
icon_color
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
# PROPERTIES
|
||||
self._icon_path = icon_path
|
||||
self._icon_color = icon_color
|
||||
|
||||
# SETUP UI
|
||||
self.setup_ui()
|
||||
|
||||
def setup_ui(self):
|
||||
# LAYOUT
|
||||
self.layout = QVBoxLayout(self)
|
||||
self.layout.setContentsMargins(0,0,0,0)
|
||||
|
||||
# LABEL
|
||||
self.icon = QLabel()
|
||||
self.icon.setAlignment(Qt.AlignCenter)
|
||||
|
||||
# PAINTER
|
||||
self.set_icon(self._icon_path, self._icon_color)
|
||||
|
||||
# ADD TO LAYOUT
|
||||
self.layout.addWidget(self.icon)
|
||||
|
||||
def set_icon(self, icon_path, icon_color = None):
|
||||
# GET COLOR
|
||||
color = ""
|
||||
if icon_color != None:
|
||||
color = icon_color
|
||||
else:
|
||||
color = self._icon_color
|
||||
|
||||
# PAINTER / PIXMAP
|
||||
icon = QPixmap(icon_path)
|
||||
painter = QPainter(icon)
|
||||
painter.setCompositionMode(QPainter.CompositionMode_SourceIn)
|
||||
painter.fillRect(icon.rect(), color)
|
||||
painter.end()
|
||||
|
||||
# SET PIXMAP
|
||||
self.icon.setPixmap(icon)
|
||||
|
||||
|
||||
@@ -1,271 +1,271 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# PY TITLE BUTTON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyLeftButton(QPushButton):
|
||||
def __init__(
|
||||
self,
|
||||
parent,
|
||||
app_parent = None,
|
||||
tooltip_text = "",
|
||||
btn_id = None,
|
||||
width = 30,
|
||||
height = 30,
|
||||
radius = 8,
|
||||
bg_color = "#343b48",
|
||||
bg_color_hover = "#3c4454",
|
||||
bg_color_pressed = "#2c313c",
|
||||
icon_color = "#c3ccdf",
|
||||
icon_color_hover = "#dce1ec",
|
||||
icon_color_pressed = "#edf0f5",
|
||||
icon_color_active = "#f5f6f9",
|
||||
icon_path = "no_icon.svg",
|
||||
dark_one = "#1b1e23",
|
||||
context_color = "#568af2",
|
||||
text_foreground = "#8a95aa",
|
||||
is_active = False
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
# SET DEFAULT PARAMETERS
|
||||
self.setFixedSize(width, height)
|
||||
self.setCursor(Qt.PointingHandCursor)
|
||||
self.setObjectName(btn_id)
|
||||
|
||||
# PROPERTIES
|
||||
self._bg_color = bg_color
|
||||
self._bg_color_hover = bg_color_hover
|
||||
self._bg_color_pressed = bg_color_pressed
|
||||
self._icon_color = icon_color
|
||||
self._icon_color_hover = icon_color_hover
|
||||
self._icon_color_pressed = icon_color_pressed
|
||||
self._icon_color_active = icon_color_active
|
||||
self._context_color = context_color
|
||||
self._top_margin = self.height() + 6
|
||||
self._is_active = is_active
|
||||
# Set Parameters
|
||||
self._set_bg_color = bg_color
|
||||
self._set_icon_path = icon_path
|
||||
self._set_icon_color = icon_color
|
||||
self._set_border_radius = radius
|
||||
# Parent
|
||||
self._parent = parent
|
||||
self._app_parent = app_parent
|
||||
|
||||
# TOOLTIP
|
||||
self._tooltip_text = tooltip_text
|
||||
self._tooltip = _ToolTip(
|
||||
app_parent,
|
||||
tooltip_text,
|
||||
dark_one,
|
||||
context_color,
|
||||
text_foreground
|
||||
)
|
||||
self._tooltip.hide()
|
||||
|
||||
# SET ACTIVE MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def set_active(self, is_active):
|
||||
self._is_active = is_active
|
||||
self.repaint()
|
||||
|
||||
# RETURN IF IS ACTIVE MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def is_active(self):
|
||||
return self._is_active
|
||||
|
||||
# PAINT EVENT
|
||||
# painting the button and the icon
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def paintEvent(self, event):
|
||||
# PAINTER
|
||||
paint = QPainter()
|
||||
paint.begin(self)
|
||||
paint.setRenderHint(QPainter.RenderHint.Antialiasing)
|
||||
|
||||
if self._is_active:
|
||||
# BRUSH
|
||||
brush = QBrush(QColor(self._bg_color_pressed))
|
||||
else:
|
||||
# BRUSH
|
||||
brush = QBrush(QColor(self._set_bg_color))
|
||||
|
||||
# CREATE RECTANGLE
|
||||
rect = QRect(0, 0, self.width(), self.height())
|
||||
paint.setPen(Qt.NoPen)
|
||||
paint.setBrush(brush)
|
||||
paint.drawRoundedRect(
|
||||
rect,
|
||||
self._set_border_radius,
|
||||
self._set_border_radius
|
||||
)
|
||||
|
||||
# DRAW ICONS
|
||||
self.icon_paint(paint, self._set_icon_path, rect)
|
||||
|
||||
# END PAINTER
|
||||
paint.end()
|
||||
|
||||
# CHANGE STYLES
|
||||
# Functions with custom styles
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def change_style(self, event):
|
||||
if event == QEvent.Enter:
|
||||
self._set_bg_color = self._bg_color_hover
|
||||
self._set_icon_color = self._icon_color_hover
|
||||
self.repaint()
|
||||
elif event == QEvent.Leave:
|
||||
self._set_bg_color = self._bg_color
|
||||
self._set_icon_color = self._icon_color
|
||||
self.repaint()
|
||||
elif event == QEvent.MouseButtonPress:
|
||||
self._set_bg_color = self._bg_color_pressed
|
||||
self._set_icon_color = self._icon_color_pressed
|
||||
self.repaint()
|
||||
elif event == QEvent.MouseButtonRelease:
|
||||
self._set_bg_color = self._bg_color_hover
|
||||
self._set_icon_color = self._icon_color_hover
|
||||
self.repaint()
|
||||
|
||||
# MOUSE OVER
|
||||
# Event triggered when the mouse is over the BTN
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def enterEvent(self, event):
|
||||
self.change_style(QEvent.Enter)
|
||||
self.move_tooltip()
|
||||
self._tooltip.show()
|
||||
|
||||
# MOUSE LEAVE
|
||||
# Event fired when the mouse leaves the BTN
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def leaveEvent(self, event):
|
||||
self.change_style(QEvent.Leave)
|
||||
self.move_tooltip()
|
||||
self._tooltip.hide()
|
||||
|
||||
# MOUSE PRESS
|
||||
# Event triggered when the left button is pressed
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def mousePressEvent(self, event):
|
||||
if event.button() == Qt.LeftButton:
|
||||
self.change_style(QEvent.MouseButtonPress)
|
||||
# SET FOCUS
|
||||
self.setFocus()
|
||||
# EMIT SIGNAL
|
||||
return self.clicked.emit()
|
||||
|
||||
# MOUSE RELEASED
|
||||
# Event triggered after the mouse button is released
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def mouseReleaseEvent(self, event):
|
||||
if event.button() == Qt.LeftButton:
|
||||
self.change_style(QEvent.MouseButtonRelease)
|
||||
# EMIT SIGNAL
|
||||
return self.released.emit()
|
||||
|
||||
# DRAW ICON WITH COLORS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def icon_paint(self, qp, image, rect):
|
||||
icon = QPixmap(image)
|
||||
painter = QPainter(icon)
|
||||
painter.setCompositionMode(QPainter.CompositionMode_SourceIn)
|
||||
if self._is_active:
|
||||
painter.fillRect(icon.rect(), self._context_color)
|
||||
else:
|
||||
painter.fillRect(icon.rect(), self._set_icon_color)
|
||||
qp.drawPixmap(
|
||||
(rect.width() - icon.width()) / 2,
|
||||
(rect.height() - icon.height()) / 2,
|
||||
icon
|
||||
)
|
||||
painter.end()
|
||||
|
||||
# SET ICON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def set_icon(self, icon_path):
|
||||
self._set_icon_path = icon_path
|
||||
self.repaint()
|
||||
|
||||
# MOVE TOOLTIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def move_tooltip(self):
|
||||
# GET MAIN WINDOW PARENT
|
||||
gp = self.mapToGlobal(QPoint(0, 0))
|
||||
|
||||
# SET WIDGET TO GET POSTION
|
||||
# Return absolute position of widget inside app
|
||||
pos = self._parent.mapFromGlobal(gp)
|
||||
|
||||
# FORMAT POSITION
|
||||
# Adjust tooltip position with offset
|
||||
pos_x = (pos.x() - self._tooltip.width()) + self.width() + 5
|
||||
pos_y = pos.y() + self._top_margin
|
||||
|
||||
# SET POSITION TO WIDGET
|
||||
# Move tooltip position
|
||||
self._tooltip.move(pos_x, pos_y)
|
||||
|
||||
# TOOLTIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class _ToolTip(QLabel):
|
||||
# TOOLTIP / LABEL StyleSheet
|
||||
style_tooltip = """
|
||||
QLabel {{
|
||||
background-color: {_dark_one};
|
||||
color: {_text_foreground};
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
border-radius: 17px;
|
||||
border: 0px solid transparent;
|
||||
border-right: 3px solid {_context_color};
|
||||
font: 800 9pt "Segoe UI";
|
||||
}}
|
||||
"""
|
||||
def __init__(
|
||||
self,
|
||||
parent,
|
||||
tooltip,
|
||||
dark_one,
|
||||
context_color,
|
||||
text_foreground
|
||||
):
|
||||
QLabel.__init__(self)
|
||||
|
||||
# LABEL SETUP
|
||||
style = self.style_tooltip.format(
|
||||
_dark_one = dark_one,
|
||||
_context_color = context_color,
|
||||
_text_foreground = text_foreground
|
||||
)
|
||||
self.setObjectName(u"label_tooltip")
|
||||
self.setStyleSheet(style)
|
||||
self.setMinimumHeight(34)
|
||||
self.setParent(parent)
|
||||
self.setText(tooltip)
|
||||
self.adjustSize()
|
||||
|
||||
# SET DROP SHADOW
|
||||
self.shadow = QGraphicsDropShadowEffect(self)
|
||||
self.shadow.setBlurRadius(30)
|
||||
self.shadow.setXOffset(0)
|
||||
self.shadow.setYOffset(0)
|
||||
self.shadow.setColor(QColor(0, 0, 0, 80))
|
||||
self.setGraphicsEffect(self.shadow)
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# PY TITLE BUTTON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyLeftButton(QPushButton):
|
||||
def __init__(
|
||||
self,
|
||||
parent,
|
||||
app_parent = None,
|
||||
tooltip_text = "",
|
||||
btn_id = None,
|
||||
width = 30,
|
||||
height = 30,
|
||||
radius = 8,
|
||||
bg_color = "#343b48",
|
||||
bg_color_hover = "#3c4454",
|
||||
bg_color_pressed = "#2c313c",
|
||||
icon_color = "#c3ccdf",
|
||||
icon_color_hover = "#dce1ec",
|
||||
icon_color_pressed = "#edf0f5",
|
||||
icon_color_active = "#f5f6f9",
|
||||
icon_path = "no_icon.svg",
|
||||
dark_one = "#1b1e23",
|
||||
context_color = "#568af2",
|
||||
text_foreground = "#8a95aa",
|
||||
is_active = False
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
# SET DEFAULT PARAMETERS
|
||||
self.setFixedSize(width, height)
|
||||
self.setCursor(Qt.PointingHandCursor)
|
||||
self.setObjectName(btn_id)
|
||||
|
||||
# PROPERTIES
|
||||
self._bg_color = bg_color
|
||||
self._bg_color_hover = bg_color_hover
|
||||
self._bg_color_pressed = bg_color_pressed
|
||||
self._icon_color = icon_color
|
||||
self._icon_color_hover = icon_color_hover
|
||||
self._icon_color_pressed = icon_color_pressed
|
||||
self._icon_color_active = icon_color_active
|
||||
self._context_color = context_color
|
||||
self._top_margin = self.height() + 6
|
||||
self._is_active = is_active
|
||||
# Set Parameters
|
||||
self._set_bg_color = bg_color
|
||||
self._set_icon_path = icon_path
|
||||
self._set_icon_color = icon_color
|
||||
self._set_border_radius = radius
|
||||
# Parent
|
||||
self._parent = parent
|
||||
self._app_parent = app_parent
|
||||
|
||||
# TOOLTIP
|
||||
self._tooltip_text = tooltip_text
|
||||
self._tooltip = _ToolTip(
|
||||
app_parent,
|
||||
tooltip_text,
|
||||
dark_one,
|
||||
context_color,
|
||||
text_foreground
|
||||
)
|
||||
self._tooltip.hide()
|
||||
|
||||
# SET ACTIVE MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def set_active(self, is_active):
|
||||
self._is_active = is_active
|
||||
self.repaint()
|
||||
|
||||
# RETURN IF IS ACTIVE MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def is_active(self):
|
||||
return self._is_active
|
||||
|
||||
# PAINT EVENT
|
||||
# painting the button and the icon
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def paintEvent(self, event):
|
||||
# PAINTER
|
||||
paint = QPainter()
|
||||
paint.begin(self)
|
||||
paint.setRenderHint(QPainter.RenderHint.Antialiasing)
|
||||
|
||||
if self._is_active:
|
||||
# BRUSH
|
||||
brush = QBrush(QColor(self._bg_color_pressed))
|
||||
else:
|
||||
# BRUSH
|
||||
brush = QBrush(QColor(self._set_bg_color))
|
||||
|
||||
# CREATE RECTANGLE
|
||||
rect = QRect(0, 0, self.width(), self.height())
|
||||
paint.setPen(Qt.NoPen)
|
||||
paint.setBrush(brush)
|
||||
paint.drawRoundedRect(
|
||||
rect,
|
||||
self._set_border_radius,
|
||||
self._set_border_radius
|
||||
)
|
||||
|
||||
# DRAW ICONS
|
||||
self.icon_paint(paint, self._set_icon_path, rect)
|
||||
|
||||
# END PAINTER
|
||||
paint.end()
|
||||
|
||||
# CHANGE STYLES
|
||||
# Functions with custom styles
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def change_style(self, event):
|
||||
if event == QEvent.Enter:
|
||||
self._set_bg_color = self._bg_color_hover
|
||||
self._set_icon_color = self._icon_color_hover
|
||||
self.repaint()
|
||||
elif event == QEvent.Leave:
|
||||
self._set_bg_color = self._bg_color
|
||||
self._set_icon_color = self._icon_color
|
||||
self.repaint()
|
||||
elif event == QEvent.MouseButtonPress:
|
||||
self._set_bg_color = self._bg_color_pressed
|
||||
self._set_icon_color = self._icon_color_pressed
|
||||
self.repaint()
|
||||
elif event == QEvent.MouseButtonRelease:
|
||||
self._set_bg_color = self._bg_color_hover
|
||||
self._set_icon_color = self._icon_color_hover
|
||||
self.repaint()
|
||||
|
||||
# MOUSE OVER
|
||||
# Event triggered when the mouse is over the BTN
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def enterEvent(self, event):
|
||||
self.change_style(QEvent.Enter)
|
||||
self.move_tooltip()
|
||||
self._tooltip.show()
|
||||
|
||||
# MOUSE LEAVE
|
||||
# Event fired when the mouse leaves the BTN
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def leaveEvent(self, event):
|
||||
self.change_style(QEvent.Leave)
|
||||
self.move_tooltip()
|
||||
self._tooltip.hide()
|
||||
|
||||
# MOUSE PRESS
|
||||
# Event triggered when the left button is pressed
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def mousePressEvent(self, event):
|
||||
if event.button() == Qt.LeftButton:
|
||||
self.change_style(QEvent.MouseButtonPress)
|
||||
# SET FOCUS
|
||||
self.setFocus()
|
||||
# EMIT SIGNAL
|
||||
return self.clicked.emit()
|
||||
|
||||
# MOUSE RELEASED
|
||||
# Event triggered after the mouse button is released
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def mouseReleaseEvent(self, event):
|
||||
if event.button() == Qt.LeftButton:
|
||||
self.change_style(QEvent.MouseButtonRelease)
|
||||
# EMIT SIGNAL
|
||||
return self.released.emit()
|
||||
|
||||
# DRAW ICON WITH COLORS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def icon_paint(self, qp, image, rect):
|
||||
icon = QPixmap(image)
|
||||
painter = QPainter(icon)
|
||||
painter.setCompositionMode(QPainter.CompositionMode_SourceIn)
|
||||
if self._is_active:
|
||||
painter.fillRect(icon.rect(), self._context_color)
|
||||
else:
|
||||
painter.fillRect(icon.rect(), self._set_icon_color)
|
||||
qp.drawPixmap(
|
||||
(rect.width() - icon.width()) / 2,
|
||||
(rect.height() - icon.height()) / 2,
|
||||
icon
|
||||
)
|
||||
painter.end()
|
||||
|
||||
# SET ICON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def set_icon(self, icon_path):
|
||||
self._set_icon_path = icon_path
|
||||
self.repaint()
|
||||
|
||||
# MOVE TOOLTIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def move_tooltip(self):
|
||||
# GET MAIN WINDOW PARENT
|
||||
gp = self.mapToGlobal(QPoint(0, 0))
|
||||
|
||||
# SET WIDGET TO GET POSTION
|
||||
# Return absolute position of widget inside app
|
||||
pos = self._parent.mapFromGlobal(gp)
|
||||
|
||||
# FORMAT POSITION
|
||||
# Adjust tooltip position with offset
|
||||
pos_x = (pos.x() - self._tooltip.width()) + self.width() + 5
|
||||
pos_y = pos.y() + self._top_margin
|
||||
|
||||
# SET POSITION TO WIDGET
|
||||
# Move tooltip position
|
||||
self._tooltip.move(pos_x, pos_y)
|
||||
|
||||
# TOOLTIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class _ToolTip(QLabel):
|
||||
# TOOLTIP / LABEL StyleSheet
|
||||
style_tooltip = """
|
||||
QLabel {{
|
||||
background-color: {_dark_one};
|
||||
color: {_text_foreground};
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
border-radius: 17px;
|
||||
border: 0px solid transparent;
|
||||
border-right: 3px solid {_context_color};
|
||||
font: 800 9pt "Segoe UI";
|
||||
}}
|
||||
"""
|
||||
def __init__(
|
||||
self,
|
||||
parent,
|
||||
tooltip,
|
||||
dark_one,
|
||||
context_color,
|
||||
text_foreground
|
||||
):
|
||||
QLabel.__init__(self)
|
||||
|
||||
# LABEL SETUP
|
||||
style = self.style_tooltip.format(
|
||||
_dark_one = dark_one,
|
||||
_context_color = context_color,
|
||||
_text_foreground = text_foreground
|
||||
)
|
||||
self.setObjectName(u"label_tooltip")
|
||||
self.setStyleSheet(style)
|
||||
self.setMinimumHeight(34)
|
||||
self.setParent(parent)
|
||||
self.setText(tooltip)
|
||||
self.adjustSize()
|
||||
|
||||
# SET DROP SHADOW
|
||||
self.shadow = QGraphicsDropShadowEffect(self)
|
||||
self.shadow.setBlurRadius(30)
|
||||
self.shadow.setXOffset(0)
|
||||
self.shadow.setYOffset(0)
|
||||
self.shadow.setColor(QColor(0, 0, 0, 80))
|
||||
self.setGraphicsEffect(self.shadow)
|
||||
|
||||
@@ -1,194 +1,194 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# IMPORT CLOSE BUTTON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_left_button import *
|
||||
|
||||
# IMPORT ICON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_icon import *
|
||||
|
||||
# IMPORT LEFT COLUMN
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from gui.uis.columns.ui_left_column import Ui_LeftColumn
|
||||
|
||||
class PyLeftColumn(QWidget):
|
||||
# SIGNALS
|
||||
clicked = Signal(object)
|
||||
released = Signal(object)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
parent,
|
||||
app_parent,
|
||||
text_title,
|
||||
text_title_size,
|
||||
text_title_color,
|
||||
dark_one,
|
||||
bg_color,
|
||||
btn_color,
|
||||
btn_color_hover,
|
||||
btn_color_pressed,
|
||||
icon_path,
|
||||
icon_color,
|
||||
icon_color_hover,
|
||||
icon_color_pressed,
|
||||
context_color,
|
||||
icon_close_path,
|
||||
radius = 8
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
# PARAMETERS
|
||||
self._parent = parent
|
||||
self._app_parent = app_parent
|
||||
self._text_title = text_title
|
||||
self._text_title_size = text_title_size
|
||||
self._text_title_color = text_title_color
|
||||
self._icon_path = icon_path
|
||||
self._dark_one = dark_one
|
||||
self._bg_color = bg_color
|
||||
self._btn_color = btn_color
|
||||
self._btn_color_hover = btn_color_hover
|
||||
self._btn_color_pressed = btn_color_pressed
|
||||
self._icon_color = icon_color
|
||||
self._icon_color_hover = icon_color_hover
|
||||
self._icon_color_pressed = icon_color_pressed
|
||||
self._context_color = context_color
|
||||
self._icon_close_path = icon_close_path
|
||||
self._radius = radius
|
||||
|
||||
# SETUP UI
|
||||
self.setup_ui()
|
||||
|
||||
# ADD LEFT COLUMN TO BG FRAME
|
||||
self.menus = Ui_LeftColumn()
|
||||
self.menus.setupUi(self.content_frame)
|
||||
|
||||
# CONNECT SIGNALS
|
||||
self.btn_close.clicked.connect(self.btn_clicked)
|
||||
self.btn_close.released.connect(self.btn_released)
|
||||
|
||||
# TITLE LEFT COLUMN EMIT SIGNALS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def btn_clicked(self):
|
||||
self.clicked.emit(self.btn_close)
|
||||
|
||||
def btn_released(self):
|
||||
self.released.emit(self.btn_close)
|
||||
|
||||
# WIDGETS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def setup_ui(self):
|
||||
# BASE LAYOUT
|
||||
self.base_layout = QVBoxLayout(self)
|
||||
self.base_layout.setContentsMargins(0,0,0,0)
|
||||
self.base_layout.setSpacing(0)
|
||||
|
||||
# TITLE FRAME
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self.title_frame = QFrame()
|
||||
self.title_frame.setMaximumHeight(47)
|
||||
self.title_frame.setMinimumHeight(47)
|
||||
|
||||
# TITLE BASE LAYOUT
|
||||
self.title_base_layout = QVBoxLayout(self.title_frame)
|
||||
self.title_base_layout.setContentsMargins(5,3,5,3)
|
||||
|
||||
# TITLE BG
|
||||
self.title_bg_frame = QFrame()
|
||||
self.title_bg_frame.setObjectName("title_bg_frame")
|
||||
self.title_bg_frame.setStyleSheet(f'''
|
||||
#title_bg_frame {{
|
||||
background-color: {self._bg_color};
|
||||
border-radius: {self._radius}px;
|
||||
}}
|
||||
''')
|
||||
|
||||
# LAYOUT TITLE BG
|
||||
self.title_bg_layout = QHBoxLayout(self.title_bg_frame)
|
||||
self.title_bg_layout.setContentsMargins(5,5,5,5)
|
||||
self.title_bg_layout.setSpacing(3)
|
||||
|
||||
# ICON
|
||||
self.icon_frame = QFrame()
|
||||
self.icon_frame.setFixedSize(30,30)
|
||||
self.icon_frame.setStyleSheet("background: none;")
|
||||
self.icon_layout = QVBoxLayout(self.icon_frame)
|
||||
self.icon_layout.setContentsMargins(0,0,0,0)
|
||||
self.icon_layout.setSpacing(5)
|
||||
self.icon = PyIcon(self._icon_path, self._icon_color)
|
||||
self.icon_layout.addWidget(self.icon, Qt.AlignCenter, Qt.AlignCenter)
|
||||
|
||||
# LABEL
|
||||
self.title_label = QLabel(self._text_title)
|
||||
self.title_label.setObjectName("title_label")
|
||||
self.title_label.setStyleSheet(f'''
|
||||
#title_label {{
|
||||
font-size: {self._text_title_size}pt;
|
||||
color: {self._text_title_color};
|
||||
padding-bottom: 2px;
|
||||
background: none;
|
||||
}}
|
||||
''')
|
||||
|
||||
# BTN FRAME
|
||||
self.btn_frame = QFrame()
|
||||
self.btn_frame.setFixedSize(30,30)
|
||||
self.btn_frame.setStyleSheet("background: none;")
|
||||
# CLOSE BUTTON
|
||||
self.btn_close = PyLeftButton(
|
||||
self._parent,
|
||||
self._app_parent,
|
||||
tooltip_text = "Hide",
|
||||
dark_one = self._dark_one,
|
||||
bg_color = self._btn_color,
|
||||
bg_color_hover = self._btn_color_hover,
|
||||
bg_color_pressed = self._btn_color_pressed,
|
||||
icon_color = self._icon_color,
|
||||
icon_color_hover = self._icon_color_hover,
|
||||
icon_color_pressed = self._icon_color_pressed,
|
||||
icon_color_active = self._icon_color_pressed,
|
||||
context_color = self._context_color,
|
||||
text_foreground = self._text_title_color,
|
||||
icon_path = self._icon_close_path,
|
||||
radius = 6,
|
||||
)
|
||||
self.btn_close.setParent(self.btn_frame)
|
||||
self.btn_close.setObjectName("btn_close_left_column")
|
||||
|
||||
# ADD TO TITLE LAYOUT
|
||||
self.title_bg_layout.addWidget(self.icon_frame)
|
||||
self.title_bg_layout.addWidget(self.title_label)
|
||||
self.title_bg_layout.addWidget(self.btn_frame)
|
||||
|
||||
# ADD TITLE BG TO LAYOUT
|
||||
self.title_base_layout.addWidget(self.title_bg_frame)
|
||||
|
||||
# CONTENT FRAME
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self.content_frame = QFrame()
|
||||
self.content_frame.setStyleSheet("background: none")
|
||||
|
||||
# ADD TO LAYOUT
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self.base_layout.addWidget(self.title_frame)
|
||||
self.base_layout.addWidget(self.content_frame)
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# IMPORT CLOSE BUTTON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_left_button import *
|
||||
|
||||
# IMPORT ICON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_icon import *
|
||||
|
||||
# IMPORT LEFT COLUMN
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from gui.uis.columns.ui_left_column import Ui_LeftColumn
|
||||
|
||||
class PyLeftColumn(QWidget):
|
||||
# SIGNALS
|
||||
clicked = Signal(object)
|
||||
released = Signal(object)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
parent,
|
||||
app_parent,
|
||||
text_title,
|
||||
text_title_size,
|
||||
text_title_color,
|
||||
dark_one,
|
||||
bg_color,
|
||||
btn_color,
|
||||
btn_color_hover,
|
||||
btn_color_pressed,
|
||||
icon_path,
|
||||
icon_color,
|
||||
icon_color_hover,
|
||||
icon_color_pressed,
|
||||
context_color,
|
||||
icon_close_path,
|
||||
radius = 8
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
# PARAMETERS
|
||||
self._parent = parent
|
||||
self._app_parent = app_parent
|
||||
self._text_title = text_title
|
||||
self._text_title_size = text_title_size
|
||||
self._text_title_color = text_title_color
|
||||
self._icon_path = icon_path
|
||||
self._dark_one = dark_one
|
||||
self._bg_color = bg_color
|
||||
self._btn_color = btn_color
|
||||
self._btn_color_hover = btn_color_hover
|
||||
self._btn_color_pressed = btn_color_pressed
|
||||
self._icon_color = icon_color
|
||||
self._icon_color_hover = icon_color_hover
|
||||
self._icon_color_pressed = icon_color_pressed
|
||||
self._context_color = context_color
|
||||
self._icon_close_path = icon_close_path
|
||||
self._radius = radius
|
||||
|
||||
# SETUP UI
|
||||
self.setup_ui()
|
||||
|
||||
# ADD LEFT COLUMN TO BG FRAME
|
||||
self.menus = Ui_LeftColumn()
|
||||
self.menus.setupUi(self.content_frame)
|
||||
|
||||
# CONNECT SIGNALS
|
||||
self.btn_close.clicked.connect(self.btn_clicked)
|
||||
self.btn_close.released.connect(self.btn_released)
|
||||
|
||||
# TITLE LEFT COLUMN EMIT SIGNALS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def btn_clicked(self):
|
||||
self.clicked.emit(self.btn_close)
|
||||
|
||||
def btn_released(self):
|
||||
self.released.emit(self.btn_close)
|
||||
|
||||
# WIDGETS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def setup_ui(self):
|
||||
# BASE LAYOUT
|
||||
self.base_layout = QVBoxLayout(self)
|
||||
self.base_layout.setContentsMargins(0,0,0,0)
|
||||
self.base_layout.setSpacing(0)
|
||||
|
||||
# TITLE FRAME
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self.title_frame = QFrame()
|
||||
self.title_frame.setMaximumHeight(47)
|
||||
self.title_frame.setMinimumHeight(47)
|
||||
|
||||
# TITLE BASE LAYOUT
|
||||
self.title_base_layout = QVBoxLayout(self.title_frame)
|
||||
self.title_base_layout.setContentsMargins(5,3,5,3)
|
||||
|
||||
# TITLE BG
|
||||
self.title_bg_frame = QFrame()
|
||||
self.title_bg_frame.setObjectName("title_bg_frame")
|
||||
self.title_bg_frame.setStyleSheet(f'''
|
||||
#title_bg_frame {{
|
||||
background-color: {self._bg_color};
|
||||
border-radius: {self._radius}px;
|
||||
}}
|
||||
''')
|
||||
|
||||
# LAYOUT TITLE BG
|
||||
self.title_bg_layout = QHBoxLayout(self.title_bg_frame)
|
||||
self.title_bg_layout.setContentsMargins(5,5,5,5)
|
||||
self.title_bg_layout.setSpacing(3)
|
||||
|
||||
# ICON
|
||||
self.icon_frame = QFrame()
|
||||
self.icon_frame.setFixedSize(30,30)
|
||||
self.icon_frame.setStyleSheet("background: none;")
|
||||
self.icon_layout = QVBoxLayout(self.icon_frame)
|
||||
self.icon_layout.setContentsMargins(0,0,0,0)
|
||||
self.icon_layout.setSpacing(5)
|
||||
self.icon = PyIcon(self._icon_path, self._icon_color)
|
||||
self.icon_layout.addWidget(self.icon, Qt.AlignCenter, Qt.AlignCenter)
|
||||
|
||||
# LABEL
|
||||
self.title_label = QLabel(self._text_title)
|
||||
self.title_label.setObjectName("title_label")
|
||||
self.title_label.setStyleSheet(f'''
|
||||
#title_label {{
|
||||
font-size: {self._text_title_size}pt;
|
||||
color: {self._text_title_color};
|
||||
padding-bottom: 2px;
|
||||
background: none;
|
||||
}}
|
||||
''')
|
||||
|
||||
# BTN FRAME
|
||||
self.btn_frame = QFrame()
|
||||
self.btn_frame.setFixedSize(30,30)
|
||||
self.btn_frame.setStyleSheet("background: none;")
|
||||
# CLOSE BUTTON
|
||||
self.btn_close = PyLeftButton(
|
||||
self._parent,
|
||||
self._app_parent,
|
||||
tooltip_text = "Hide",
|
||||
dark_one = self._dark_one,
|
||||
bg_color = self._btn_color,
|
||||
bg_color_hover = self._btn_color_hover,
|
||||
bg_color_pressed = self._btn_color_pressed,
|
||||
icon_color = self._icon_color,
|
||||
icon_color_hover = self._icon_color_hover,
|
||||
icon_color_pressed = self._icon_color_pressed,
|
||||
icon_color_active = self._icon_color_pressed,
|
||||
context_color = self._context_color,
|
||||
text_foreground = self._text_title_color,
|
||||
icon_path = self._icon_close_path,
|
||||
radius = 6,
|
||||
)
|
||||
self.btn_close.setParent(self.btn_frame)
|
||||
self.btn_close.setObjectName("btn_close_left_column")
|
||||
|
||||
# ADD TO TITLE LAYOUT
|
||||
self.title_bg_layout.addWidget(self.icon_frame)
|
||||
self.title_bg_layout.addWidget(self.title_label)
|
||||
self.title_bg_layout.addWidget(self.btn_frame)
|
||||
|
||||
# ADD TITLE BG TO LAYOUT
|
||||
self.title_base_layout.addWidget(self.title_bg_frame)
|
||||
|
||||
# CONTENT FRAME
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self.content_frame = QFrame()
|
||||
self.content_frame.setStyleSheet("background: none")
|
||||
|
||||
# ADD TO LAYOUT
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self.base_layout.addWidget(self.title_frame)
|
||||
self.base_layout.addWidget(self.content_frame)
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# PY LEFT MENU
|
||||
# Left menu bar
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# PY LEFT MENU
|
||||
# Left menu bar
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_left_menu import PyLeftMenu
|
||||
@@ -1,34 +1,34 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# CUSTOM LEFT MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyDiv(QWidget):
|
||||
def __init__(self, color):
|
||||
super().__init__()
|
||||
|
||||
self.layout = QHBoxLayout(self)
|
||||
self.layout.setContentsMargins(5,0,5,0)
|
||||
self.frame_line = QFrame()
|
||||
self.frame_line.setStyleSheet(f"background: {color};")
|
||||
self.frame_line.setMaximumHeight(1)
|
||||
self.frame_line.setMinimumHeight(1)
|
||||
self.layout.addWidget(self.frame_line)
|
||||
self.setMaximumHeight(1)
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# CUSTOM LEFT MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyDiv(QWidget):
|
||||
def __init__(self, color):
|
||||
super().__init__()
|
||||
|
||||
self.layout = QHBoxLayout(self)
|
||||
self.layout.setContentsMargins(5,0,5,0)
|
||||
self.frame_line = QFrame()
|
||||
self.frame_line.setStyleSheet(f"background: {color};")
|
||||
self.frame_line.setMaximumHeight(1)
|
||||
self.frame_line.setMinimumHeight(1)
|
||||
self.layout.addWidget(self.frame_line)
|
||||
self.setMaximumHeight(1)
|
||||
|
||||
@@ -1,266 +1,266 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# IMPORT BUTTON AND DIV
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_left_menu_button import PyLeftMenuButton
|
||||
from . py_div import PyDiv
|
||||
|
||||
# IMPORT FUNCTIONS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from gui.core.functions import *
|
||||
|
||||
# PY LEFT MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyLeftMenu(QWidget):
|
||||
# SIGNALS
|
||||
clicked = Signal(object)
|
||||
released = Signal(object)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
parent = None,
|
||||
app_parent = None,
|
||||
dark_one = "#1b1e23",
|
||||
dark_three = "#21252d",
|
||||
dark_four = "#272c36",
|
||||
bg_one = "#2c313c",
|
||||
icon_color = "#c3ccdf",
|
||||
icon_color_hover = "#dce1ec",
|
||||
icon_color_pressed = "#edf0f5",
|
||||
icon_color_active = "#f5f6f9",
|
||||
context_color = "#568af2",
|
||||
text_foreground = "#8a95aa",
|
||||
text_active = "#dce1ec",
|
||||
duration_time = 500,
|
||||
radius = 8,
|
||||
minimum_width = 50,
|
||||
maximum_width = 240,
|
||||
icon_path = "icon_menu.svg",
|
||||
icon_path_close = "icon_menu_close.svg",
|
||||
toggle_text = "Hide Menu",
|
||||
toggle_tooltip = "Show menu"
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
# PROPERTIES
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self._dark_one = dark_one
|
||||
self._dark_three = dark_three
|
||||
self._dark_four = dark_four
|
||||
self._bg_one = bg_one
|
||||
self._icon_color = icon_color
|
||||
self._icon_color_hover = icon_color_hover
|
||||
self._icon_color_pressed = icon_color_pressed
|
||||
self._icon_color_active = icon_color_active
|
||||
self._context_color = context_color
|
||||
self._text_foreground = text_foreground
|
||||
self._text_active = text_active
|
||||
self._duration_time = duration_time
|
||||
self._radius = radius
|
||||
self._minimum_width = minimum_width
|
||||
self._maximum_width = maximum_width
|
||||
self._icon_path = Functions.set_svg_icon(icon_path)
|
||||
self._icon_path_close = Functions.set_svg_icon(icon_path_close)
|
||||
|
||||
# SET PARENT
|
||||
self._parent = parent
|
||||
self._app_parent = app_parent
|
||||
|
||||
# SETUP WIDGETS
|
||||
self.setup_ui()
|
||||
|
||||
# SET BG COLOR
|
||||
self.bg.setStyleSheet(f"background: {dark_one}; border-radius: {radius};")
|
||||
|
||||
# TOGGLE BUTTON AND DIV MENUS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self.toggle_button = PyLeftMenuButton(
|
||||
app_parent,
|
||||
text = toggle_text,
|
||||
tooltip_text = toggle_tooltip,
|
||||
dark_one = self._dark_one,
|
||||
dark_three = self._dark_three,
|
||||
dark_four = self._dark_four,
|
||||
bg_one = self._bg_one,
|
||||
icon_color = self._icon_color,
|
||||
icon_color_hover = self._icon_color_active,
|
||||
icon_color_pressed = self._icon_color_pressed,
|
||||
icon_color_active = self._icon_color_active,
|
||||
context_color = self._context_color,
|
||||
text_foreground = self._text_foreground,
|
||||
text_active = self._text_active,
|
||||
icon_path = icon_path
|
||||
)
|
||||
self.toggle_button.clicked.connect(self.toggle_animation)
|
||||
self.div_top = PyDiv(dark_four)
|
||||
|
||||
# ADD TO TOP LAYOUT
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self.top_layout.addWidget(self.toggle_button)
|
||||
self.top_layout.addWidget(self.div_top)
|
||||
|
||||
# ADD TO BOTTOM LAYOUT
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self.div_bottom = PyDiv(dark_four)
|
||||
self.div_bottom.hide()
|
||||
self.bottom_layout.addWidget(self.div_bottom)
|
||||
|
||||
# ADD BUTTONS TO LEFT MENU
|
||||
# Add btns and emit signals
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def add_menus(self, parameters):
|
||||
if parameters != None:
|
||||
for parameter in parameters:
|
||||
_btn_icon = parameter['btn_icon']
|
||||
_btn_id = parameter['btn_id']
|
||||
_btn_text = parameter['btn_text']
|
||||
_btn_tooltip = parameter['btn_tooltip']
|
||||
_show_top = parameter['show_top']
|
||||
_is_active = parameter['is_active']
|
||||
|
||||
self.menu = PyLeftMenuButton(
|
||||
self._app_parent,
|
||||
text = _btn_text,
|
||||
btn_id = _btn_id,
|
||||
tooltip_text = _btn_tooltip,
|
||||
dark_one = self._dark_one,
|
||||
dark_three = self._dark_three,
|
||||
dark_four = self._dark_four,
|
||||
bg_one = self._bg_one,
|
||||
icon_color = self._icon_color,
|
||||
icon_color_hover = self._icon_color_active,
|
||||
icon_color_pressed = self._icon_color_pressed,
|
||||
icon_color_active = self._icon_color_active,
|
||||
context_color = self._context_color,
|
||||
text_foreground = self._text_foreground,
|
||||
text_active = self._text_active,
|
||||
icon_path = _btn_icon,
|
||||
is_active = _is_active
|
||||
)
|
||||
self.menu.clicked.connect(self.btn_clicked)
|
||||
self.menu.released.connect(self.btn_released)
|
||||
|
||||
# ADD TO LAYOUT
|
||||
if _show_top:
|
||||
self.top_layout.addWidget(self.menu)
|
||||
else:
|
||||
self.div_bottom.show()
|
||||
self.bottom_layout.addWidget(self.menu)
|
||||
|
||||
# LEFT MENU EMIT SIGNALS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def btn_clicked(self):
|
||||
self.clicked.emit(self.menu)
|
||||
|
||||
def btn_released(self):
|
||||
self.released.emit(self.menu)
|
||||
|
||||
# EXPAND / RETRACT LEF MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def toggle_animation(self):
|
||||
# CREATE ANIMATION
|
||||
self.animation = QPropertyAnimation(self._parent, b"minimumWidth")
|
||||
self.animation.stop()
|
||||
if self.width() == self._minimum_width:
|
||||
self.animation.setStartValue(self.width())
|
||||
self.animation.setEndValue(self._maximum_width)
|
||||
self.toggle_button.set_active_toggle(True)
|
||||
self.toggle_button.set_icon(self._icon_path_close)
|
||||
else:
|
||||
self.animation.setStartValue(self.width())
|
||||
self.animation.setEndValue(self._minimum_width)
|
||||
self.toggle_button.set_active_toggle(False)
|
||||
self.toggle_button.set_icon(self._icon_path)
|
||||
self.animation.setEasingCurve(QEasingCurve.InOutCubic)
|
||||
self.animation.setDuration(self._duration_time)
|
||||
self.animation.start()
|
||||
|
||||
# SELECT ONLY ONE BTN
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def select_only_one(self, widget: str):
|
||||
for btn in self.findChildren(QPushButton):
|
||||
if btn.objectName() == widget:
|
||||
btn.set_active(True)
|
||||
else:
|
||||
btn.set_active(False)
|
||||
|
||||
# SELECT ONLY ONE TAB BTN
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def select_only_one_tab(self, widget: str):
|
||||
for btn in self.findChildren(QPushButton):
|
||||
if btn.objectName() == widget:
|
||||
btn.set_active_tab(True)
|
||||
else:
|
||||
btn.set_active_tab(False)
|
||||
|
||||
# DESELECT ALL BTNs
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def deselect_all(self):
|
||||
for btn in self.findChildren(QPushButton):
|
||||
btn.set_active(False)
|
||||
|
||||
# DESELECT ALL TAB BTNs
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def deselect_all_tab(self):
|
||||
for btn in self.findChildren(QPushButton):
|
||||
btn.set_active_tab(False)
|
||||
|
||||
# SETUP APP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def setup_ui(self):
|
||||
# ADD MENU LAYOUT
|
||||
self.left_menu_layout = QVBoxLayout(self)
|
||||
self.left_menu_layout.setContentsMargins(0,0,0,0)
|
||||
|
||||
# ADD BG
|
||||
self.bg = QFrame()
|
||||
|
||||
# TOP FRAME
|
||||
self.top_frame = QFrame()
|
||||
|
||||
# BOTTOM FRAME
|
||||
self.bottom_frame = QFrame()
|
||||
|
||||
# ADD LAYOUTS
|
||||
self._layout = QVBoxLayout(self.bg)
|
||||
self._layout.setContentsMargins(0,0,0,0)
|
||||
|
||||
# TOP LAYOUT
|
||||
self.top_layout = QVBoxLayout(self.top_frame)
|
||||
self.top_layout.setContentsMargins(0,0,0,0)
|
||||
self.top_layout.setSpacing(1)
|
||||
|
||||
# BOTTOM LAYOUT
|
||||
self.bottom_layout = QVBoxLayout(self.bottom_frame)
|
||||
self.bottom_layout.setContentsMargins(0,0,0,8)
|
||||
self.bottom_layout.setSpacing(1)
|
||||
|
||||
# ADD TOP AND BOTTOM FRAME
|
||||
self._layout.addWidget(self.top_frame, 0, Qt.AlignTop)
|
||||
self._layout.addWidget(self.bottom_frame, 0, Qt.AlignBottom)
|
||||
|
||||
# ADD BG TO LAYOUT
|
||||
self.left_menu_layout.addWidget(self.bg)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# IMPORT BUTTON AND DIV
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_left_menu_button import PyLeftMenuButton
|
||||
from . py_div import PyDiv
|
||||
|
||||
# IMPORT FUNCTIONS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from gui.core.functions import *
|
||||
|
||||
# PY LEFT MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyLeftMenu(QWidget):
|
||||
# SIGNALS
|
||||
clicked = Signal(object)
|
||||
released = Signal(object)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
parent = None,
|
||||
app_parent = None,
|
||||
dark_one = "#1b1e23",
|
||||
dark_three = "#21252d",
|
||||
dark_four = "#272c36",
|
||||
bg_one = "#2c313c",
|
||||
icon_color = "#c3ccdf",
|
||||
icon_color_hover = "#dce1ec",
|
||||
icon_color_pressed = "#edf0f5",
|
||||
icon_color_active = "#f5f6f9",
|
||||
context_color = "#568af2",
|
||||
text_foreground = "#8a95aa",
|
||||
text_active = "#dce1ec",
|
||||
duration_time = 500,
|
||||
radius = 8,
|
||||
minimum_width = 50,
|
||||
maximum_width = 240,
|
||||
icon_path = "icon_menu.svg",
|
||||
icon_path_close = "icon_menu_close.svg",
|
||||
toggle_text = "Hide Menu",
|
||||
toggle_tooltip = "Show menu"
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
# PROPERTIES
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self._dark_one = dark_one
|
||||
self._dark_three = dark_three
|
||||
self._dark_four = dark_four
|
||||
self._bg_one = bg_one
|
||||
self._icon_color = icon_color
|
||||
self._icon_color_hover = icon_color_hover
|
||||
self._icon_color_pressed = icon_color_pressed
|
||||
self._icon_color_active = icon_color_active
|
||||
self._context_color = context_color
|
||||
self._text_foreground = text_foreground
|
||||
self._text_active = text_active
|
||||
self._duration_time = duration_time
|
||||
self._radius = radius
|
||||
self._minimum_width = minimum_width
|
||||
self._maximum_width = maximum_width
|
||||
self._icon_path = Functions.set_svg_icon(icon_path)
|
||||
self._icon_path_close = Functions.set_svg_icon(icon_path_close)
|
||||
|
||||
# SET PARENT
|
||||
self._parent = parent
|
||||
self._app_parent = app_parent
|
||||
|
||||
# SETUP WIDGETS
|
||||
self.setup_ui()
|
||||
|
||||
# SET BG COLOR
|
||||
self.bg.setStyleSheet(f"background: {dark_one}; border-radius: {radius};")
|
||||
|
||||
# TOGGLE BUTTON AND DIV MENUS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self.toggle_button = PyLeftMenuButton(
|
||||
app_parent,
|
||||
text = toggle_text,
|
||||
tooltip_text = toggle_tooltip,
|
||||
dark_one = self._dark_one,
|
||||
dark_three = self._dark_three,
|
||||
dark_four = self._dark_four,
|
||||
bg_one = self._bg_one,
|
||||
icon_color = self._icon_color,
|
||||
icon_color_hover = self._icon_color_active,
|
||||
icon_color_pressed = self._icon_color_pressed,
|
||||
icon_color_active = self._icon_color_active,
|
||||
context_color = self._context_color,
|
||||
text_foreground = self._text_foreground,
|
||||
text_active = self._text_active,
|
||||
icon_path = icon_path
|
||||
)
|
||||
self.toggle_button.clicked.connect(self.toggle_animation)
|
||||
self.div_top = PyDiv(dark_four)
|
||||
|
||||
# ADD TO TOP LAYOUT
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self.top_layout.addWidget(self.toggle_button)
|
||||
self.top_layout.addWidget(self.div_top)
|
||||
|
||||
# ADD TO BOTTOM LAYOUT
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self.div_bottom = PyDiv(dark_four)
|
||||
self.div_bottom.hide()
|
||||
self.bottom_layout.addWidget(self.div_bottom)
|
||||
|
||||
# ADD BUTTONS TO LEFT MENU
|
||||
# Add btns and emit signals
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def add_menus(self, parameters):
|
||||
if parameters != None:
|
||||
for parameter in parameters:
|
||||
_btn_icon = parameter['btn_icon']
|
||||
_btn_id = parameter['btn_id']
|
||||
_btn_text = parameter['btn_text']
|
||||
_btn_tooltip = parameter['btn_tooltip']
|
||||
_show_top = parameter['show_top']
|
||||
_is_active = parameter['is_active']
|
||||
|
||||
self.menu = PyLeftMenuButton(
|
||||
self._app_parent,
|
||||
text = _btn_text,
|
||||
btn_id = _btn_id,
|
||||
tooltip_text = _btn_tooltip,
|
||||
dark_one = self._dark_one,
|
||||
dark_three = self._dark_three,
|
||||
dark_four = self._dark_four,
|
||||
bg_one = self._bg_one,
|
||||
icon_color = self._icon_color,
|
||||
icon_color_hover = self._icon_color_active,
|
||||
icon_color_pressed = self._icon_color_pressed,
|
||||
icon_color_active = self._icon_color_active,
|
||||
context_color = self._context_color,
|
||||
text_foreground = self._text_foreground,
|
||||
text_active = self._text_active,
|
||||
icon_path = _btn_icon,
|
||||
is_active = _is_active
|
||||
)
|
||||
self.menu.clicked.connect(self.btn_clicked)
|
||||
self.menu.released.connect(self.btn_released)
|
||||
|
||||
# ADD TO LAYOUT
|
||||
if _show_top:
|
||||
self.top_layout.addWidget(self.menu)
|
||||
else:
|
||||
self.div_bottom.show()
|
||||
self.bottom_layout.addWidget(self.menu)
|
||||
|
||||
# LEFT MENU EMIT SIGNALS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def btn_clicked(self):
|
||||
self.clicked.emit(self.menu)
|
||||
|
||||
def btn_released(self):
|
||||
self.released.emit(self.menu)
|
||||
|
||||
# EXPAND / RETRACT LEF MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def toggle_animation(self):
|
||||
# CREATE ANIMATION
|
||||
self.animation = QPropertyAnimation(self._parent, b"minimumWidth")
|
||||
self.animation.stop()
|
||||
if self.width() == self._minimum_width:
|
||||
self.animation.setStartValue(self.width())
|
||||
self.animation.setEndValue(self._maximum_width)
|
||||
self.toggle_button.set_active_toggle(True)
|
||||
self.toggle_button.set_icon(self._icon_path_close)
|
||||
else:
|
||||
self.animation.setStartValue(self.width())
|
||||
self.animation.setEndValue(self._minimum_width)
|
||||
self.toggle_button.set_active_toggle(False)
|
||||
self.toggle_button.set_icon(self._icon_path)
|
||||
self.animation.setEasingCurve(QEasingCurve.InOutCubic)
|
||||
self.animation.setDuration(self._duration_time)
|
||||
self.animation.start()
|
||||
|
||||
# SELECT ONLY ONE BTN
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def select_only_one(self, widget: str):
|
||||
for btn in self.findChildren(QPushButton):
|
||||
if btn.objectName() == widget:
|
||||
btn.set_active(True)
|
||||
else:
|
||||
btn.set_active(False)
|
||||
|
||||
# SELECT ONLY ONE TAB BTN
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def select_only_one_tab(self, widget: str):
|
||||
for btn in self.findChildren(QPushButton):
|
||||
if btn.objectName() == widget:
|
||||
btn.set_active_tab(True)
|
||||
else:
|
||||
btn.set_active_tab(False)
|
||||
|
||||
# DESELECT ALL BTNs
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def deselect_all(self):
|
||||
for btn in self.findChildren(QPushButton):
|
||||
btn.set_active(False)
|
||||
|
||||
# DESELECT ALL TAB BTNs
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def deselect_all_tab(self):
|
||||
for btn in self.findChildren(QPushButton):
|
||||
btn.set_active_tab(False)
|
||||
|
||||
# SETUP APP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def setup_ui(self):
|
||||
# ADD MENU LAYOUT
|
||||
self.left_menu_layout = QVBoxLayout(self)
|
||||
self.left_menu_layout.setContentsMargins(0,0,0,0)
|
||||
|
||||
# ADD BG
|
||||
self.bg = QFrame()
|
||||
|
||||
# TOP FRAME
|
||||
self.top_frame = QFrame()
|
||||
|
||||
# BOTTOM FRAME
|
||||
self.bottom_frame = QFrame()
|
||||
|
||||
# ADD LAYOUTS
|
||||
self._layout = QVBoxLayout(self.bg)
|
||||
self._layout.setContentsMargins(0,0,0,0)
|
||||
|
||||
# TOP LAYOUT
|
||||
self.top_layout = QVBoxLayout(self.top_frame)
|
||||
self.top_layout.setContentsMargins(0,0,0,0)
|
||||
self.top_layout.setSpacing(1)
|
||||
|
||||
# BOTTOM LAYOUT
|
||||
self.bottom_layout = QVBoxLayout(self.bottom_frame)
|
||||
self.bottom_layout.setContentsMargins(0,0,0,8)
|
||||
self.bottom_layout.setSpacing(1)
|
||||
|
||||
# ADD TOP AND BOTTOM FRAME
|
||||
self._layout.addWidget(self.top_frame, 0, Qt.AlignTop)
|
||||
self._layout.addWidget(self.bottom_frame, 0, Qt.AlignBottom)
|
||||
|
||||
# ADD BG TO LAYOUT
|
||||
self.left_menu_layout.addWidget(self.bg)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,380 +1,380 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT PACKAGES AND MODULES
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
import os
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# IMPORT FUNCTIONS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from gui.core.functions import *
|
||||
|
||||
# CUSTOM LEFT MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyLeftMenuButton(QPushButton):
|
||||
def __init__(
|
||||
self,
|
||||
app_parent,
|
||||
text,
|
||||
btn_id = None,
|
||||
tooltip_text = "",
|
||||
margin = 4,
|
||||
dark_one = "#1b1e23",
|
||||
dark_three = "#21252d",
|
||||
dark_four = "#272c36",
|
||||
bg_one = "#2c313c",
|
||||
icon_color = "#c3ccdf",
|
||||
icon_color_hover = "#dce1ec",
|
||||
icon_color_pressed = "#edf0f5",
|
||||
icon_color_active = "#f5f6f9",
|
||||
context_color = "#568af2",
|
||||
text_foreground = "#8a95aa",
|
||||
text_active = "#dce1ec",
|
||||
icon_path = "icon_add_user.svg",
|
||||
icon_active_menu = "active_menu.svg",
|
||||
is_active = False,
|
||||
is_active_tab = False,
|
||||
is_toggle_active = False
|
||||
):
|
||||
super().__init__()
|
||||
self.setText(text)
|
||||
self.setCursor(Qt.PointingHandCursor)
|
||||
self.setMaximumHeight(50)
|
||||
self.setMinimumHeight(50)
|
||||
self.setObjectName(btn_id)
|
||||
|
||||
# APP PATH
|
||||
self._icon_path = Functions.set_svg_icon(icon_path)
|
||||
self._icon_active_menu = Functions.set_svg_icon(icon_active_menu)
|
||||
|
||||
# PROPERTIES
|
||||
self._margin = margin
|
||||
self._dark_one = dark_one
|
||||
self._dark_three = dark_three
|
||||
self._dark_four = dark_four
|
||||
self._bg_one = bg_one
|
||||
self._context_color = context_color
|
||||
self._icon_color = icon_color
|
||||
self._icon_color_hover = icon_color_hover
|
||||
self._icon_color_pressed = icon_color_pressed
|
||||
self._icon_color_active = icon_color_active
|
||||
self._set_icon_color = self._icon_color # Set icon color
|
||||
self._set_bg_color = self._dark_one # Set BG color
|
||||
self._set_text_foreground = text_foreground
|
||||
self._set_text_active = text_active
|
||||
self._parent = app_parent
|
||||
self._is_active = is_active
|
||||
self._is_active_tab = is_active_tab
|
||||
self._is_toggle_active = is_toggle_active
|
||||
|
||||
# TOOLTIP
|
||||
self._tooltip_text = tooltip_text
|
||||
self.tooltip = _ToolTip(
|
||||
app_parent,
|
||||
tooltip_text,
|
||||
dark_one,
|
||||
context_color,
|
||||
text_foreground
|
||||
)
|
||||
self.tooltip.hide()
|
||||
|
||||
# PAINT EVENT
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def paintEvent(self, event):
|
||||
# PAINTER
|
||||
p = QPainter()
|
||||
p.begin(self)
|
||||
p.setRenderHint(QPainter.Antialiasing)
|
||||
p.setPen(Qt.NoPen)
|
||||
p.setFont(self.font())
|
||||
|
||||
# RECTANGLES
|
||||
rect = QRect(4, 5, self.width(), self.height() - 10)
|
||||
rect_inside = QRect(4, 5, self.width() - 8, self.height() - 10)
|
||||
rect_icon = QRect(0, 0, 50, self.height())
|
||||
rect_blue = QRect(4, 5, 20, self.height() - 10)
|
||||
rect_inside_active = QRect(7, 5, self.width(), self.height() - 10)
|
||||
rect_text = QRect(45, 0, self.width() - 50, self.height())
|
||||
|
||||
if self._is_active:
|
||||
# DRAW BG BLUE
|
||||
p.setBrush(QColor(self._context_color))
|
||||
p.drawRoundedRect(rect_blue, 8, 8)
|
||||
|
||||
# BG INSIDE
|
||||
p.setBrush(QColor(self._bg_one))
|
||||
p.drawRoundedRect(rect_inside_active, 8, 8)
|
||||
|
||||
# DRAW ACTIVE
|
||||
icon_path = self._icon_active_menu
|
||||
app_path = os.path.abspath(os.getcwd())
|
||||
icon_path = os.path.normpath(os.path.join(app_path, icon_path))
|
||||
self._set_icon_color = self._icon_color_active
|
||||
self.icon_active(p, icon_path, self.width())
|
||||
|
||||
# DRAW TEXT
|
||||
p.setPen(QColor(self._set_text_active))
|
||||
p.drawText(rect_text, Qt.AlignVCenter, self.text())
|
||||
|
||||
# DRAW ICONS
|
||||
self.icon_paint(p, self._icon_path, rect_icon, self._set_icon_color)
|
||||
|
||||
elif self._is_active_tab:
|
||||
# DRAW BG BLUE
|
||||
p.setBrush(QColor(self._dark_four))
|
||||
p.drawRoundedRect(rect_blue, 8, 8)
|
||||
|
||||
# BG INSIDE
|
||||
p.setBrush(QColor(self._bg_one))
|
||||
p.drawRoundedRect(rect_inside_active, 8, 8)
|
||||
|
||||
# DRAW ACTIVE
|
||||
icon_path = self._icon_active_menu
|
||||
app_path = os.path.abspath(os.getcwd())
|
||||
icon_path = os.path.normpath(os.path.join(app_path, icon_path))
|
||||
self._set_icon_color = self._icon_color_active
|
||||
self.icon_active(p, icon_path, self.width())
|
||||
|
||||
# DRAW TEXT
|
||||
p.setPen(QColor(self._set_text_active))
|
||||
p.drawText(rect_text, Qt.AlignVCenter, self.text())
|
||||
|
||||
# DRAW ICONS
|
||||
self.icon_paint(p, self._icon_path, rect_icon, self._set_icon_color)
|
||||
|
||||
# NORMAL BG
|
||||
else:
|
||||
if self._is_toggle_active:
|
||||
# BG INSIDE
|
||||
p.setBrush(QColor(self._dark_three))
|
||||
p.drawRoundedRect(rect_inside, 8, 8)
|
||||
|
||||
# DRAW TEXT
|
||||
p.setPen(QColor(self._set_text_foreground))
|
||||
p.drawText(rect_text, Qt.AlignVCenter, self.text())
|
||||
|
||||
# DRAW ICONS
|
||||
if self._is_toggle_active:
|
||||
self.icon_paint(p, self._icon_path, rect_icon, self._context_color)
|
||||
else:
|
||||
self.icon_paint(p, self._icon_path, rect_icon, self._set_icon_color)
|
||||
else:
|
||||
# BG INSIDE
|
||||
p.setBrush(QColor(self._set_bg_color))
|
||||
p.drawRoundedRect(rect_inside, 8, 8)
|
||||
|
||||
# DRAW TEXT
|
||||
p.setPen(QColor(self._set_text_foreground))
|
||||
p.drawText(rect_text, Qt.AlignVCenter, self.text())
|
||||
|
||||
# DRAW ICONS
|
||||
self.icon_paint(p, self._icon_path, rect_icon, self._set_icon_color)
|
||||
|
||||
p.end()
|
||||
|
||||
# SET ACTIVE MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def set_active(self, is_active):
|
||||
self._is_active = is_active
|
||||
if not is_active:
|
||||
self._set_icon_color = self._icon_color
|
||||
self._set_bg_color = self._dark_one
|
||||
|
||||
self.repaint()
|
||||
|
||||
# SET ACTIVE TAB MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def set_active_tab(self, is_active):
|
||||
self._is_active_tab = is_active
|
||||
if not is_active:
|
||||
self._set_icon_color = self._icon_color
|
||||
self._set_bg_color = self._dark_one
|
||||
|
||||
self.repaint()
|
||||
|
||||
# RETURN IF IS ACTIVE MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def is_active(self):
|
||||
return self._is_active
|
||||
|
||||
# RETURN IF IS ACTIVE TAB MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def is_active_tab(self):
|
||||
return self._is_active_tab
|
||||
|
||||
# SET ACTIVE TOGGLE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def set_active_toggle(self, is_active):
|
||||
self._is_toggle_active = is_active
|
||||
|
||||
# SET ICON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def set_icon(self, icon_path):
|
||||
self._icon_path = icon_path
|
||||
self.repaint()
|
||||
|
||||
# DRAW ICON WITH COLORS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def icon_paint(self, qp, image, rect, color):
|
||||
icon = QPixmap(image)
|
||||
painter = QPainter(icon)
|
||||
painter.setCompositionMode(QPainter.CompositionMode_SourceIn)
|
||||
painter.fillRect(icon.rect(), color)
|
||||
qp.drawPixmap(
|
||||
(rect.width() - icon.width()) / 2,
|
||||
(rect.height() - icon.height()) / 2,
|
||||
icon
|
||||
)
|
||||
painter.end()
|
||||
|
||||
# DRAW ACTIVE ICON / RIGHT SIDE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def icon_active(self, qp, image, width):
|
||||
icon = QPixmap(image)
|
||||
painter = QPainter(icon)
|
||||
painter.setCompositionMode(QPainter.CompositionMode_SourceIn)
|
||||
painter.fillRect(icon.rect(), self._bg_one)
|
||||
qp.drawPixmap(width - 5, 0, icon)
|
||||
painter.end()
|
||||
|
||||
# CHANGE STYLES
|
||||
# Functions with custom styles
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def change_style(self, event):
|
||||
if event == QEvent.Enter:
|
||||
if not self._is_active:
|
||||
self._set_icon_color = self._icon_color_hover
|
||||
self._set_bg_color = self._dark_three
|
||||
self.repaint()
|
||||
elif event == QEvent.Leave:
|
||||
if not self._is_active:
|
||||
self._set_icon_color = self._icon_color
|
||||
self._set_bg_color = self._dark_one
|
||||
self.repaint()
|
||||
elif event == QEvent.MouseButtonPress:
|
||||
if not self._is_active:
|
||||
self._set_icon_color = self._context_color
|
||||
self._set_bg_color = self._dark_four
|
||||
self.repaint()
|
||||
elif event == QEvent.MouseButtonRelease:
|
||||
if not self._is_active:
|
||||
self._set_icon_color = self._icon_color_hover
|
||||
self._set_bg_color = self._dark_three
|
||||
self.repaint()
|
||||
|
||||
# MOUSE OVER
|
||||
# Event triggered when the mouse is over the BTN
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def enterEvent(self, event):
|
||||
self.change_style(QEvent.Enter)
|
||||
if self.width() == 50 and self._tooltip_text:
|
||||
self.move_tooltip()
|
||||
self.tooltip.show()
|
||||
|
||||
# MOUSE LEAVE
|
||||
# Event fired when the mouse leaves the BTN
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def leaveEvent(self, event):
|
||||
self.change_style(QEvent.Leave)
|
||||
self.tooltip.hide()
|
||||
|
||||
# MOUSE PRESS
|
||||
# Event triggered when the left button is pressed
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def mousePressEvent(self, event):
|
||||
if event.button() == Qt.LeftButton:
|
||||
self.change_style(QEvent.MouseButtonPress)
|
||||
self.tooltip.hide()
|
||||
return self.clicked.emit()
|
||||
|
||||
# MOUSE RELEASED
|
||||
# Event triggered after the mouse button is released
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def mouseReleaseEvent(self, event):
|
||||
if event.button() == Qt.LeftButton:
|
||||
self.change_style(QEvent.MouseButtonRelease)
|
||||
return self.released.emit()
|
||||
|
||||
# MOVE TOOLTIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def move_tooltip(self):
|
||||
# GET MAIN WINDOW PARENT
|
||||
gp = self.mapToGlobal(QPoint(0, 0))
|
||||
|
||||
# SET WIDGET TO GET POSTION
|
||||
# Return absolute position of widget inside app
|
||||
pos = self._parent.mapFromGlobal(gp)
|
||||
|
||||
# FORMAT POSITION
|
||||
# Adjust tooltip position with offset
|
||||
pos_x = pos.x() + self.width() + 5
|
||||
pos_y = pos.y() + (self.width() - self.tooltip.height()) // 2
|
||||
|
||||
# SET POSITION TO WIDGET
|
||||
# Move tooltip position
|
||||
self.tooltip.move(pos_x, pos_y)
|
||||
|
||||
class _ToolTip(QLabel):
|
||||
# TOOLTIP / LABEL StyleSheet
|
||||
style_tooltip = """
|
||||
QLabel {{
|
||||
background-color: {_dark_one};
|
||||
color: {_text_foreground};
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
border-radius: 17px;
|
||||
border: 0px solid transparent;
|
||||
border-left: 3px solid {_context_color};
|
||||
font: 800 9pt "Segoe UI";
|
||||
}}
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
parent,
|
||||
tooltip,
|
||||
dark_one,
|
||||
context_color,
|
||||
text_foreground
|
||||
):
|
||||
QLabel.__init__(self)
|
||||
|
||||
# LABEL SETUP
|
||||
style = self.style_tooltip.format(
|
||||
_dark_one = dark_one,
|
||||
_context_color = context_color,
|
||||
_text_foreground = text_foreground
|
||||
)
|
||||
self.setObjectName(u"label_tooltip")
|
||||
self.setStyleSheet(style)
|
||||
self.setMinimumHeight(34)
|
||||
self.setParent(parent)
|
||||
self.setText(tooltip)
|
||||
self.adjustSize()
|
||||
|
||||
# SET DROP SHADOW
|
||||
self.shadow = QGraphicsDropShadowEffect(self)
|
||||
self.shadow.setBlurRadius(30)
|
||||
self.shadow.setXOffset(0)
|
||||
self.shadow.setYOffset(0)
|
||||
self.shadow.setColor(QColor(0, 0, 0, 80))
|
||||
self.setGraphicsEffect(self.shadow)
|
||||
|
||||
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT PACKAGES AND MODULES
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
import os
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# IMPORT FUNCTIONS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from gui.core.functions import *
|
||||
|
||||
# CUSTOM LEFT MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyLeftMenuButton(QPushButton):
|
||||
def __init__(
|
||||
self,
|
||||
app_parent,
|
||||
text,
|
||||
btn_id = None,
|
||||
tooltip_text = "",
|
||||
margin = 4,
|
||||
dark_one = "#1b1e23",
|
||||
dark_three = "#21252d",
|
||||
dark_four = "#272c36",
|
||||
bg_one = "#2c313c",
|
||||
icon_color = "#c3ccdf",
|
||||
icon_color_hover = "#dce1ec",
|
||||
icon_color_pressed = "#edf0f5",
|
||||
icon_color_active = "#f5f6f9",
|
||||
context_color = "#568af2",
|
||||
text_foreground = "#8a95aa",
|
||||
text_active = "#dce1ec",
|
||||
icon_path = "icon_add_user.svg",
|
||||
icon_active_menu = "active_menu.svg",
|
||||
is_active = False,
|
||||
is_active_tab = False,
|
||||
is_toggle_active = False
|
||||
):
|
||||
super().__init__()
|
||||
self.setText(text)
|
||||
self.setCursor(Qt.PointingHandCursor)
|
||||
self.setMaximumHeight(50)
|
||||
self.setMinimumHeight(50)
|
||||
self.setObjectName(btn_id)
|
||||
|
||||
# APP PATH
|
||||
self._icon_path = Functions.set_svg_icon(icon_path)
|
||||
self._icon_active_menu = Functions.set_svg_icon(icon_active_menu)
|
||||
|
||||
# PROPERTIES
|
||||
self._margin = margin
|
||||
self._dark_one = dark_one
|
||||
self._dark_three = dark_three
|
||||
self._dark_four = dark_four
|
||||
self._bg_one = bg_one
|
||||
self._context_color = context_color
|
||||
self._icon_color = icon_color
|
||||
self._icon_color_hover = icon_color_hover
|
||||
self._icon_color_pressed = icon_color_pressed
|
||||
self._icon_color_active = icon_color_active
|
||||
self._set_icon_color = self._icon_color # Set icon color
|
||||
self._set_bg_color = self._dark_one # Set BG color
|
||||
self._set_text_foreground = text_foreground
|
||||
self._set_text_active = text_active
|
||||
self._parent = app_parent
|
||||
self._is_active = is_active
|
||||
self._is_active_tab = is_active_tab
|
||||
self._is_toggle_active = is_toggle_active
|
||||
|
||||
# TOOLTIP
|
||||
self._tooltip_text = tooltip_text
|
||||
self.tooltip = _ToolTip(
|
||||
app_parent,
|
||||
tooltip_text,
|
||||
dark_one,
|
||||
context_color,
|
||||
text_foreground
|
||||
)
|
||||
self.tooltip.hide()
|
||||
|
||||
# PAINT EVENT
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def paintEvent(self, event):
|
||||
# PAINTER
|
||||
p = QPainter()
|
||||
p.begin(self)
|
||||
p.setRenderHint(QPainter.Antialiasing)
|
||||
p.setPen(Qt.NoPen)
|
||||
p.setFont(self.font())
|
||||
|
||||
# RECTANGLES
|
||||
rect = QRect(4, 5, self.width(), self.height() - 10)
|
||||
rect_inside = QRect(4, 5, self.width() - 8, self.height() - 10)
|
||||
rect_icon = QRect(0, 0, 50, self.height())
|
||||
rect_blue = QRect(4, 5, 20, self.height() - 10)
|
||||
rect_inside_active = QRect(7, 5, self.width(), self.height() - 10)
|
||||
rect_text = QRect(45, 0, self.width() - 50, self.height())
|
||||
|
||||
if self._is_active:
|
||||
# DRAW BG BLUE
|
||||
p.setBrush(QColor(self._context_color))
|
||||
p.drawRoundedRect(rect_blue, 8, 8)
|
||||
|
||||
# BG INSIDE
|
||||
p.setBrush(QColor(self._bg_one))
|
||||
p.drawRoundedRect(rect_inside_active, 8, 8)
|
||||
|
||||
# DRAW ACTIVE
|
||||
icon_path = self._icon_active_menu
|
||||
app_path = os.path.abspath(os.getcwd())
|
||||
icon_path = os.path.normpath(os.path.join(app_path, icon_path))
|
||||
self._set_icon_color = self._icon_color_active
|
||||
self.icon_active(p, icon_path, self.width())
|
||||
|
||||
# DRAW TEXT
|
||||
p.setPen(QColor(self._set_text_active))
|
||||
p.drawText(rect_text, Qt.AlignVCenter, self.text())
|
||||
|
||||
# DRAW ICONS
|
||||
self.icon_paint(p, self._icon_path, rect_icon, self._set_icon_color)
|
||||
|
||||
elif self._is_active_tab:
|
||||
# DRAW BG BLUE
|
||||
p.setBrush(QColor(self._dark_four))
|
||||
p.drawRoundedRect(rect_blue, 8, 8)
|
||||
|
||||
# BG INSIDE
|
||||
p.setBrush(QColor(self._bg_one))
|
||||
p.drawRoundedRect(rect_inside_active, 8, 8)
|
||||
|
||||
# DRAW ACTIVE
|
||||
icon_path = self._icon_active_menu
|
||||
app_path = os.path.abspath(os.getcwd())
|
||||
icon_path = os.path.normpath(os.path.join(app_path, icon_path))
|
||||
self._set_icon_color = self._icon_color_active
|
||||
self.icon_active(p, icon_path, self.width())
|
||||
|
||||
# DRAW TEXT
|
||||
p.setPen(QColor(self._set_text_active))
|
||||
p.drawText(rect_text, Qt.AlignVCenter, self.text())
|
||||
|
||||
# DRAW ICONS
|
||||
self.icon_paint(p, self._icon_path, rect_icon, self._set_icon_color)
|
||||
|
||||
# NORMAL BG
|
||||
else:
|
||||
if self._is_toggle_active:
|
||||
# BG INSIDE
|
||||
p.setBrush(QColor(self._dark_three))
|
||||
p.drawRoundedRect(rect_inside, 8, 8)
|
||||
|
||||
# DRAW TEXT
|
||||
p.setPen(QColor(self._set_text_foreground))
|
||||
p.drawText(rect_text, Qt.AlignVCenter, self.text())
|
||||
|
||||
# DRAW ICONS
|
||||
if self._is_toggle_active:
|
||||
self.icon_paint(p, self._icon_path, rect_icon, self._context_color)
|
||||
else:
|
||||
self.icon_paint(p, self._icon_path, rect_icon, self._set_icon_color)
|
||||
else:
|
||||
# BG INSIDE
|
||||
p.setBrush(QColor(self._set_bg_color))
|
||||
p.drawRoundedRect(rect_inside, 8, 8)
|
||||
|
||||
# DRAW TEXT
|
||||
p.setPen(QColor(self._set_text_foreground))
|
||||
p.drawText(rect_text, Qt.AlignVCenter, self.text())
|
||||
|
||||
# DRAW ICONS
|
||||
self.icon_paint(p, self._icon_path, rect_icon, self._set_icon_color)
|
||||
|
||||
p.end()
|
||||
|
||||
# SET ACTIVE MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def set_active(self, is_active):
|
||||
self._is_active = is_active
|
||||
if not is_active:
|
||||
self._set_icon_color = self._icon_color
|
||||
self._set_bg_color = self._dark_one
|
||||
|
||||
self.repaint()
|
||||
|
||||
# SET ACTIVE TAB MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def set_active_tab(self, is_active):
|
||||
self._is_active_tab = is_active
|
||||
if not is_active:
|
||||
self._set_icon_color = self._icon_color
|
||||
self._set_bg_color = self._dark_one
|
||||
|
||||
self.repaint()
|
||||
|
||||
# RETURN IF IS ACTIVE MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def is_active(self):
|
||||
return self._is_active
|
||||
|
||||
# RETURN IF IS ACTIVE TAB MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def is_active_tab(self):
|
||||
return self._is_active_tab
|
||||
|
||||
# SET ACTIVE TOGGLE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def set_active_toggle(self, is_active):
|
||||
self._is_toggle_active = is_active
|
||||
|
||||
# SET ICON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def set_icon(self, icon_path):
|
||||
self._icon_path = icon_path
|
||||
self.repaint()
|
||||
|
||||
# DRAW ICON WITH COLORS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def icon_paint(self, qp, image, rect, color):
|
||||
icon = QPixmap(image)
|
||||
painter = QPainter(icon)
|
||||
painter.setCompositionMode(QPainter.CompositionMode_SourceIn)
|
||||
painter.fillRect(icon.rect(), color)
|
||||
qp.drawPixmap(
|
||||
(rect.width() - icon.width()) / 2,
|
||||
(rect.height() - icon.height()) / 2,
|
||||
icon
|
||||
)
|
||||
painter.end()
|
||||
|
||||
# DRAW ACTIVE ICON / RIGHT SIDE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def icon_active(self, qp, image, width):
|
||||
icon = QPixmap(image)
|
||||
painter = QPainter(icon)
|
||||
painter.setCompositionMode(QPainter.CompositionMode_SourceIn)
|
||||
painter.fillRect(icon.rect(), self._bg_one)
|
||||
qp.drawPixmap(width - 5, 0, icon)
|
||||
painter.end()
|
||||
|
||||
# CHANGE STYLES
|
||||
# Functions with custom styles
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def change_style(self, event):
|
||||
if event == QEvent.Enter:
|
||||
if not self._is_active:
|
||||
self._set_icon_color = self._icon_color_hover
|
||||
self._set_bg_color = self._dark_three
|
||||
self.repaint()
|
||||
elif event == QEvent.Leave:
|
||||
if not self._is_active:
|
||||
self._set_icon_color = self._icon_color
|
||||
self._set_bg_color = self._dark_one
|
||||
self.repaint()
|
||||
elif event == QEvent.MouseButtonPress:
|
||||
if not self._is_active:
|
||||
self._set_icon_color = self._context_color
|
||||
self._set_bg_color = self._dark_four
|
||||
self.repaint()
|
||||
elif event == QEvent.MouseButtonRelease:
|
||||
if not self._is_active:
|
||||
self._set_icon_color = self._icon_color_hover
|
||||
self._set_bg_color = self._dark_three
|
||||
self.repaint()
|
||||
|
||||
# MOUSE OVER
|
||||
# Event triggered when the mouse is over the BTN
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def enterEvent(self, event):
|
||||
self.change_style(QEvent.Enter)
|
||||
if self.width() == 50 and self._tooltip_text:
|
||||
self.move_tooltip()
|
||||
self.tooltip.show()
|
||||
|
||||
# MOUSE LEAVE
|
||||
# Event fired when the mouse leaves the BTN
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def leaveEvent(self, event):
|
||||
self.change_style(QEvent.Leave)
|
||||
self.tooltip.hide()
|
||||
|
||||
# MOUSE PRESS
|
||||
# Event triggered when the left button is pressed
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def mousePressEvent(self, event):
|
||||
if event.button() == Qt.LeftButton:
|
||||
self.change_style(QEvent.MouseButtonPress)
|
||||
self.tooltip.hide()
|
||||
return self.clicked.emit()
|
||||
|
||||
# MOUSE RELEASED
|
||||
# Event triggered after the mouse button is released
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def mouseReleaseEvent(self, event):
|
||||
if event.button() == Qt.LeftButton:
|
||||
self.change_style(QEvent.MouseButtonRelease)
|
||||
return self.released.emit()
|
||||
|
||||
# MOVE TOOLTIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def move_tooltip(self):
|
||||
# GET MAIN WINDOW PARENT
|
||||
gp = self.mapToGlobal(QPoint(0, 0))
|
||||
|
||||
# SET WIDGET TO GET POSTION
|
||||
# Return absolute position of widget inside app
|
||||
pos = self._parent.mapFromGlobal(gp)
|
||||
|
||||
# FORMAT POSITION
|
||||
# Adjust tooltip position with offset
|
||||
pos_x = pos.x() + self.width() + 5
|
||||
pos_y = pos.y() + (self.width() - self.tooltip.height()) // 2
|
||||
|
||||
# SET POSITION TO WIDGET
|
||||
# Move tooltip position
|
||||
self.tooltip.move(pos_x, pos_y)
|
||||
|
||||
class _ToolTip(QLabel):
|
||||
# TOOLTIP / LABEL StyleSheet
|
||||
style_tooltip = """
|
||||
QLabel {{
|
||||
background-color: {_dark_one};
|
||||
color: {_text_foreground};
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
border-radius: 17px;
|
||||
border: 0px solid transparent;
|
||||
border-left: 3px solid {_context_color};
|
||||
font: 800 9pt "Segoe UI";
|
||||
}}
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
parent,
|
||||
tooltip,
|
||||
dark_one,
|
||||
context_color,
|
||||
text_foreground
|
||||
):
|
||||
QLabel.__init__(self)
|
||||
|
||||
# LABEL SETUP
|
||||
style = self.style_tooltip.format(
|
||||
_dark_one = dark_one,
|
||||
_context_color = context_color,
|
||||
_text_foreground = text_foreground
|
||||
)
|
||||
self.setObjectName(u"label_tooltip")
|
||||
self.setStyleSheet(style)
|
||||
self.setMinimumHeight(34)
|
||||
self.setParent(parent)
|
||||
self.setText(tooltip)
|
||||
self.adjustSize()
|
||||
|
||||
# SET DROP SHADOW
|
||||
self.shadow = QGraphicsDropShadowEffect(self)
|
||||
self.shadow.setBlurRadius(30)
|
||||
self.shadow.setXOffset(0)
|
||||
self.shadow.setYOffset(0)
|
||||
self.shadow.setColor(QColor(0, 0, 0, 80))
|
||||
self.setGraphicsEffect(self.shadow)
|
||||
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# PY LINE EDIT
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# PY LINE EDIT
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_line_edit import PyLineEdit
|
||||
@@ -1,95 +1,95 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# STYLE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
style = '''
|
||||
QLineEdit {{
|
||||
background-color: {_bg_color};
|
||||
border-radius: {_radius}px;
|
||||
border: {_border_size}px solid transparent;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
selection-color: {_selection_color};
|
||||
selection-background-color: {_context_color};
|
||||
color: {_color};
|
||||
}}
|
||||
QLineEdit:focus {{
|
||||
border: {_border_size}px solid {_context_color};
|
||||
background-color: {_bg_color_active};
|
||||
}}
|
||||
'''
|
||||
|
||||
# PY PUSH BUTTON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyLineEdit(QLineEdit):
|
||||
def __init__(
|
||||
self,
|
||||
text = "",
|
||||
place_holder_text = "",
|
||||
radius = 8,
|
||||
border_size = 2,
|
||||
color = "#FFF",
|
||||
selection_color = "#FFF",
|
||||
bg_color = "#333",
|
||||
bg_color_active = "#222",
|
||||
context_color = "#00ABE8"
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
# PARAMETERS
|
||||
if text:
|
||||
self.setText(text)
|
||||
if place_holder_text:
|
||||
self.setPlaceholderText(place_holder_text)
|
||||
|
||||
# SET STYLESHEET
|
||||
self.set_stylesheet(
|
||||
radius,
|
||||
border_size,
|
||||
color,
|
||||
selection_color,
|
||||
bg_color,
|
||||
bg_color_active,
|
||||
context_color
|
||||
)
|
||||
|
||||
# SET STYLESHEET
|
||||
def set_stylesheet(
|
||||
self,
|
||||
radius,
|
||||
border_size,
|
||||
color,
|
||||
selection_color,
|
||||
bg_color,
|
||||
bg_color_active,
|
||||
context_color
|
||||
):
|
||||
# APPLY STYLESHEET
|
||||
style_format = style.format(
|
||||
_radius = radius,
|
||||
_border_size = border_size,
|
||||
_color = color,
|
||||
_selection_color = selection_color,
|
||||
_bg_color = bg_color,
|
||||
_bg_color_active = bg_color_active,
|
||||
_context_color = context_color
|
||||
)
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# STYLE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
style = '''
|
||||
QLineEdit {{
|
||||
background-color: {_bg_color};
|
||||
border-radius: {_radius}px;
|
||||
border: {_border_size}px solid transparent;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
selection-color: {_selection_color};
|
||||
selection-background-color: {_context_color};
|
||||
color: {_color};
|
||||
}}
|
||||
QLineEdit:focus {{
|
||||
border: {_border_size}px solid {_context_color};
|
||||
background-color: {_bg_color_active};
|
||||
}}
|
||||
'''
|
||||
|
||||
# PY PUSH BUTTON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyLineEdit(QLineEdit):
|
||||
def __init__(
|
||||
self,
|
||||
text = "",
|
||||
place_holder_text = "",
|
||||
radius = 8,
|
||||
border_size = 2,
|
||||
color = "#FFF",
|
||||
selection_color = "#FFF",
|
||||
bg_color = "#333",
|
||||
bg_color_active = "#222",
|
||||
context_color = "#00ABE8"
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
# PARAMETERS
|
||||
if text:
|
||||
self.setText(text)
|
||||
if place_holder_text:
|
||||
self.setPlaceholderText(place_holder_text)
|
||||
|
||||
# SET STYLESHEET
|
||||
self.set_stylesheet(
|
||||
radius,
|
||||
border_size,
|
||||
color,
|
||||
selection_color,
|
||||
bg_color,
|
||||
bg_color_active,
|
||||
context_color
|
||||
)
|
||||
|
||||
# SET STYLESHEET
|
||||
def set_stylesheet(
|
||||
self,
|
||||
radius,
|
||||
border_size,
|
||||
color,
|
||||
selection_color,
|
||||
bg_color,
|
||||
bg_color_active,
|
||||
context_color
|
||||
):
|
||||
# APPLY STYLESHEET
|
||||
style_format = style.format(
|
||||
_radius = radius,
|
||||
_border_size = border_size,
|
||||
_color = color,
|
||||
_selection_color = selection_color,
|
||||
_bg_color = bg_color,
|
||||
_bg_color_active = bg_color_active,
|
||||
_context_color = context_color
|
||||
)
|
||||
self.setStyleSheet(style_format)
|
||||
@@ -1,19 +1,19 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# PY PUSH BUTTON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# PY PUSH BUTTON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_push_button import PyPushButton
|
||||
@@ -1,71 +1,71 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# STYLE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
style = '''
|
||||
QPushButton {{
|
||||
border: none;
|
||||
padding-left: 10px;
|
||||
padding-right: 5px;
|
||||
color: {_color};
|
||||
border-radius: {_radius};
|
||||
background-color: {_bg_color};
|
||||
}}
|
||||
QPushButton:hover {{
|
||||
background-color: {_bg_color_hover};
|
||||
}}
|
||||
QPushButton:pressed {{
|
||||
background-color: {_bg_color_pressed};
|
||||
}}
|
||||
'''
|
||||
|
||||
# PY PUSH BUTTON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyPushButton(QPushButton):
|
||||
def __init__(
|
||||
self,
|
||||
text,
|
||||
radius,
|
||||
color,
|
||||
bg_color,
|
||||
bg_color_hover,
|
||||
bg_color_pressed,
|
||||
parent = None,
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
# SET PARAMETRES
|
||||
self.setText(text)
|
||||
if parent != None:
|
||||
self.setParent(parent)
|
||||
self.setCursor(Qt.PointingHandCursor)
|
||||
|
||||
# SET STYLESHEET
|
||||
custom_style = style.format(
|
||||
_color = color,
|
||||
_radius = radius,
|
||||
_bg_color = bg_color,
|
||||
_bg_color_hover = bg_color_hover,
|
||||
_bg_color_pressed = bg_color_pressed
|
||||
)
|
||||
self.setStyleSheet(custom_style)
|
||||
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# STYLE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
style = '''
|
||||
QPushButton {{
|
||||
border: none;
|
||||
padding-left: 10px;
|
||||
padding-right: 5px;
|
||||
color: {_color};
|
||||
border-radius: {_radius};
|
||||
background-color: {_bg_color};
|
||||
}}
|
||||
QPushButton:hover {{
|
||||
background-color: {_bg_color_hover};
|
||||
}}
|
||||
QPushButton:pressed {{
|
||||
background-color: {_bg_color_pressed};
|
||||
}}
|
||||
'''
|
||||
|
||||
# PY PUSH BUTTON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyPushButton(QPushButton):
|
||||
def __init__(
|
||||
self,
|
||||
text,
|
||||
radius,
|
||||
color,
|
||||
bg_color,
|
||||
bg_color_hover,
|
||||
bg_color_pressed,
|
||||
parent = None,
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
# SET PARAMETRES
|
||||
self.setText(text)
|
||||
if parent != None:
|
||||
self.setParent(parent)
|
||||
self.setCursor(Qt.PointingHandCursor)
|
||||
|
||||
# SET STYLESHEET
|
||||
custom_style = style.format(
|
||||
_color = color,
|
||||
_radius = radius,
|
||||
_bg_color = bg_color,
|
||||
_bg_color_hover = bg_color_hover,
|
||||
_bg_color_pressed = bg_color_pressed
|
||||
)
|
||||
self.setStyleSheet(custom_style)
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# PY SLIDER
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# PY SLIDER
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_slider import PySlider
|
||||
@@ -1,97 +1,97 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
style = """
|
||||
/* HORIZONTAL */
|
||||
QSlider {{ margin: {_margin}px; }}
|
||||
QSlider::groove:horizontal {{
|
||||
border-radius: {_bg_radius}px;
|
||||
height: {_bg_size}px;
|
||||
margin: 0px;
|
||||
background-color: {_bg_color};
|
||||
}}
|
||||
QSlider::groove:horizontal:hover {{ background-color: {_bg_color_hover}; }}
|
||||
QSlider::handle:horizontal {{
|
||||
border: none;
|
||||
height: {_handle_size}px;
|
||||
width: {_handle_size}px;
|
||||
margin: {_handle_margin}px;
|
||||
border-radius: {_handle_radius}px;
|
||||
background-color: {_handle_color};
|
||||
}}
|
||||
QSlider::handle:horizontal:hover {{ background-color: {_handle_color_hover}; }}
|
||||
QSlider::handle:horizontal:pressed {{ background-color: {_handle_color_pressed}; }}
|
||||
|
||||
/* VERTICAL */
|
||||
QSlider::groove:vertical {{
|
||||
border-radius: {_bg_radius}px;
|
||||
width: {_bg_size}px;
|
||||
margin: 0px;
|
||||
background-color: {_bg_color};
|
||||
}}
|
||||
QSlider::groove:vertical:hover {{ background-color: {_bg_color_hover}; }}
|
||||
QSlider::handle:vertical {{
|
||||
border: none;
|
||||
height: {_handle_size}px;
|
||||
width: {_handle_size}px;
|
||||
margin: {_handle_margin}px;
|
||||
border-radius: {_handle_radius}px;
|
||||
background-color: {_handle_color};
|
||||
}}
|
||||
QSlider::handle:vertical:hover {{ background-color: {_handle_color_hover}; }}
|
||||
QSlider::handle:vertical:pressed {{ background-color: {_handle_color_pressed}; }}
|
||||
"""
|
||||
|
||||
class PySlider(QSlider):
|
||||
def __init__(
|
||||
self,
|
||||
margin = 0,
|
||||
bg_size = 20,
|
||||
bg_radius = 10,
|
||||
bg_color = "#1b1e23",
|
||||
bg_color_hover = "#1e2229",
|
||||
handle_margin = 2,
|
||||
handle_size = 16,
|
||||
handle_radius = 8,
|
||||
handle_color = "#568af2",
|
||||
handle_color_hover = "#6c99f4",
|
||||
handle_color_pressed = "#3f6fd1"
|
||||
):
|
||||
super(PySlider, self).__init__()
|
||||
|
||||
# FORMAT STYLE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
adjust_style = style.format(
|
||||
_margin = margin,
|
||||
_bg_size = bg_size,
|
||||
_bg_radius = bg_radius,
|
||||
_bg_color = bg_color,
|
||||
_bg_color_hover = bg_color_hover,
|
||||
_handle_margin = handle_margin,
|
||||
_handle_size = handle_size,
|
||||
_handle_radius = handle_radius,
|
||||
_handle_color = handle_color,
|
||||
_handle_color_hover = handle_color_hover,
|
||||
_handle_color_pressed = handle_color_pressed
|
||||
)
|
||||
|
||||
# APPLY CUSTOM STYLE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
style = """
|
||||
/* HORIZONTAL */
|
||||
QSlider {{ margin: {_margin}px; }}
|
||||
QSlider::groove:horizontal {{
|
||||
border-radius: {_bg_radius}px;
|
||||
height: {_bg_size}px;
|
||||
margin: 0px;
|
||||
background-color: {_bg_color};
|
||||
}}
|
||||
QSlider::groove:horizontal:hover {{ background-color: {_bg_color_hover}; }}
|
||||
QSlider::handle:horizontal {{
|
||||
border: none;
|
||||
height: {_handle_size}px;
|
||||
width: {_handle_size}px;
|
||||
margin: {_handle_margin}px;
|
||||
border-radius: {_handle_radius}px;
|
||||
background-color: {_handle_color};
|
||||
}}
|
||||
QSlider::handle:horizontal:hover {{ background-color: {_handle_color_hover}; }}
|
||||
QSlider::handle:horizontal:pressed {{ background-color: {_handle_color_pressed}; }}
|
||||
|
||||
/* VERTICAL */
|
||||
QSlider::groove:vertical {{
|
||||
border-radius: {_bg_radius}px;
|
||||
width: {_bg_size}px;
|
||||
margin: 0px;
|
||||
background-color: {_bg_color};
|
||||
}}
|
||||
QSlider::groove:vertical:hover {{ background-color: {_bg_color_hover}; }}
|
||||
QSlider::handle:vertical {{
|
||||
border: none;
|
||||
height: {_handle_size}px;
|
||||
width: {_handle_size}px;
|
||||
margin: {_handle_margin}px;
|
||||
border-radius: {_handle_radius}px;
|
||||
background-color: {_handle_color};
|
||||
}}
|
||||
QSlider::handle:vertical:hover {{ background-color: {_handle_color_hover}; }}
|
||||
QSlider::handle:vertical:pressed {{ background-color: {_handle_color_pressed}; }}
|
||||
"""
|
||||
|
||||
class PySlider(QSlider):
|
||||
def __init__(
|
||||
self,
|
||||
margin = 0,
|
||||
bg_size = 20,
|
||||
bg_radius = 10,
|
||||
bg_color = "#1b1e23",
|
||||
bg_color_hover = "#1e2229",
|
||||
handle_margin = 2,
|
||||
handle_size = 16,
|
||||
handle_radius = 8,
|
||||
handle_color = "#568af2",
|
||||
handle_color_hover = "#6c99f4",
|
||||
handle_color_pressed = "#3f6fd1"
|
||||
):
|
||||
super(PySlider, self).__init__()
|
||||
|
||||
# FORMAT STYLE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
adjust_style = style.format(
|
||||
_margin = margin,
|
||||
_bg_size = bg_size,
|
||||
_bg_radius = bg_radius,
|
||||
_bg_color = bg_color,
|
||||
_bg_color_hover = bg_color_hover,
|
||||
_handle_margin = handle_margin,
|
||||
_handle_size = handle_size,
|
||||
_handle_radius = handle_radius,
|
||||
_handle_color = handle_color,
|
||||
_handle_color_hover = handle_color_hover,
|
||||
_handle_color_pressed = handle_color_pressed
|
||||
)
|
||||
|
||||
# APPLY CUSTOM STYLE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self.setStyleSheet(adjust_style)
|
||||
@@ -1,19 +1,19 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# PY TABLE WIDGET
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# PY TABLE WIDGET
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_table_widget import PyTableWidget
|
||||
@@ -1,90 +1,90 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# IMPORT STYLE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . style import *
|
||||
|
||||
# PY PUSH BUTTON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyTableWidget(QTableWidget):
|
||||
def __init__(
|
||||
self,
|
||||
radius = 8,
|
||||
color = "#FFF",
|
||||
bg_color = "#444",
|
||||
selection_color = "#FFF",
|
||||
header_horizontal_color = "#333",
|
||||
header_vertical_color = "#444",
|
||||
bottom_line_color = "#555",
|
||||
grid_line_color = "#555",
|
||||
scroll_bar_bg_color = "#FFF",
|
||||
scroll_bar_btn_color = "#3333",
|
||||
context_color = "#00ABE8"
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
# PARAMETERS
|
||||
|
||||
# SET STYLESHEET
|
||||
self.set_stylesheet(
|
||||
radius,
|
||||
color,
|
||||
bg_color,
|
||||
header_horizontal_color,
|
||||
header_vertical_color,
|
||||
selection_color,
|
||||
bottom_line_color,
|
||||
grid_line_color,
|
||||
scroll_bar_bg_color,
|
||||
scroll_bar_btn_color,
|
||||
context_color
|
||||
)
|
||||
|
||||
# SET STYLESHEET
|
||||
def set_stylesheet(
|
||||
self,
|
||||
radius,
|
||||
color,
|
||||
bg_color,
|
||||
header_horizontal_color,
|
||||
header_vertical_color,
|
||||
selection_color,
|
||||
bottom_line_color,
|
||||
grid_line_color,
|
||||
scroll_bar_bg_color,
|
||||
scroll_bar_btn_color,
|
||||
context_color
|
||||
):
|
||||
# APPLY STYLESHEET
|
||||
style_format = style.format(
|
||||
_radius = radius,
|
||||
_color = color,
|
||||
_bg_color = bg_color,
|
||||
_header_horizontal_color = header_horizontal_color,
|
||||
_header_vertical_color = header_vertical_color,
|
||||
_selection_color = selection_color,
|
||||
_bottom_line_color = bottom_line_color,
|
||||
_grid_line_color = grid_line_color,
|
||||
_scroll_bar_bg_color = scroll_bar_bg_color,
|
||||
_scroll_bar_btn_color = scroll_bar_btn_color,
|
||||
_context_color = context_color
|
||||
)
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# IMPORT STYLE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . style import *
|
||||
|
||||
# PY PUSH BUTTON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyTableWidget(QTableWidget):
|
||||
def __init__(
|
||||
self,
|
||||
radius = 8,
|
||||
color = "#FFF",
|
||||
bg_color = "#444",
|
||||
selection_color = "#FFF",
|
||||
header_horizontal_color = "#333",
|
||||
header_vertical_color = "#444",
|
||||
bottom_line_color = "#555",
|
||||
grid_line_color = "#555",
|
||||
scroll_bar_bg_color = "#FFF",
|
||||
scroll_bar_btn_color = "#3333",
|
||||
context_color = "#00ABE8"
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
# PARAMETERS
|
||||
|
||||
# SET STYLESHEET
|
||||
self.set_stylesheet(
|
||||
radius,
|
||||
color,
|
||||
bg_color,
|
||||
header_horizontal_color,
|
||||
header_vertical_color,
|
||||
selection_color,
|
||||
bottom_line_color,
|
||||
grid_line_color,
|
||||
scroll_bar_bg_color,
|
||||
scroll_bar_btn_color,
|
||||
context_color
|
||||
)
|
||||
|
||||
# SET STYLESHEET
|
||||
def set_stylesheet(
|
||||
self,
|
||||
radius,
|
||||
color,
|
||||
bg_color,
|
||||
header_horizontal_color,
|
||||
header_vertical_color,
|
||||
selection_color,
|
||||
bottom_line_color,
|
||||
grid_line_color,
|
||||
scroll_bar_bg_color,
|
||||
scroll_bar_btn_color,
|
||||
context_color
|
||||
):
|
||||
# APPLY STYLESHEET
|
||||
style_format = style.format(
|
||||
_radius = radius,
|
||||
_color = color,
|
||||
_bg_color = bg_color,
|
||||
_header_horizontal_color = header_horizontal_color,
|
||||
_header_vertical_color = header_vertical_color,
|
||||
_selection_color = selection_color,
|
||||
_bottom_line_color = bottom_line_color,
|
||||
_grid_line_color = grid_line_color,
|
||||
_scroll_bar_bg_color = scroll_bar_bg_color,
|
||||
_scroll_bar_btn_color = scroll_bar_btn_color,
|
||||
_context_color = context_color
|
||||
)
|
||||
self.setStyleSheet(style_format)
|
||||
@@ -1,135 +1,135 @@
|
||||
# STYLE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
style = '''
|
||||
/* /////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
QTableWidget */
|
||||
|
||||
QTableWidget {{
|
||||
background-color: {_bg_color};
|
||||
padding: 5px;
|
||||
border-radius: {_radius}px;
|
||||
gridline-color: {_grid_line_color};
|
||||
color: {_color};
|
||||
}}
|
||||
QTableWidget::item{{
|
||||
border-color: none;
|
||||
padding-left: 5px;
|
||||
padding-right: 5px;
|
||||
gridline-color: rgb(44, 49, 60);
|
||||
border-bottom: 1px solid {_bottom_line_color};
|
||||
}}
|
||||
QTableWidget::item:selected{{
|
||||
background-color: {_selection_color};
|
||||
}}
|
||||
QHeaderView::section{{
|
||||
background-color: rgb(33, 37, 43);
|
||||
max-width: 30px;
|
||||
border: 1px solid rgb(44, 49, 58);
|
||||
border-style: none;
|
||||
border-bottom: 1px solid rgb(44, 49, 60);
|
||||
border-right: 1px solid rgb(44, 49, 60);
|
||||
}}
|
||||
QTableWidget::horizontalHeader {{
|
||||
background-color: rgb(33, 37, 43);
|
||||
}}
|
||||
QTableWidget QTableCornerButton::section {{
|
||||
border: none;
|
||||
background-color: {_header_horizontal_color};
|
||||
padding: 3px;
|
||||
border-top-left-radius: {_radius}px;
|
||||
}}
|
||||
QHeaderView::section:horizontal
|
||||
{{
|
||||
border: none;
|
||||
background-color: {_header_horizontal_color};
|
||||
padding: 3px;
|
||||
}}
|
||||
QHeaderView::section:vertical
|
||||
{{
|
||||
border: none;
|
||||
background-color: {_header_vertical_color};
|
||||
padding-left: 5px;
|
||||
padding-right: 5px;
|
||||
border-bottom: 1px solid {_bottom_line_color};
|
||||
margin-bottom: 1px;
|
||||
}}
|
||||
|
||||
|
||||
/* /////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
ScrollBars */
|
||||
QScrollBar:horizontal {{
|
||||
border: none;
|
||||
background: {_scroll_bar_bg_color};
|
||||
height: 8px;
|
||||
margin: 0px 21px 0 21px;
|
||||
border-radius: 0px;
|
||||
}}
|
||||
QScrollBar::handle:horizontal {{
|
||||
background: {_context_color};
|
||||
min-width: 25px;
|
||||
border-radius: 4px
|
||||
}}
|
||||
QScrollBar::add-line:horizontal {{
|
||||
border: none;
|
||||
background: {_scroll_bar_btn_color};
|
||||
width: 20px;
|
||||
border-top-right-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
subcontrol-position: right;
|
||||
subcontrol-origin: margin;
|
||||
}}
|
||||
QScrollBar::sub-line:horizontal {{
|
||||
border: none;
|
||||
background: {_scroll_bar_btn_color};
|
||||
width: 20px;
|
||||
border-top-left-radius: 4px;
|
||||
border-bottom-left-radius: 4px;
|
||||
subcontrol-position: left;
|
||||
subcontrol-origin: margin;
|
||||
}}
|
||||
QScrollBar::up-arrow:horizontal, QScrollBar::down-arrow:horizontal
|
||||
{{
|
||||
background: none;
|
||||
}}
|
||||
QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal
|
||||
{{
|
||||
background: none;
|
||||
}}
|
||||
QScrollBar:vertical {{
|
||||
border: none;
|
||||
background: {_scroll_bar_bg_color};
|
||||
width: 8px;
|
||||
margin: 21px 0 21px 0;
|
||||
border-radius: 0px;
|
||||
}}
|
||||
QScrollBar::handle:vertical {{
|
||||
background: {_context_color};
|
||||
min-height: 25px;
|
||||
border-radius: 4px
|
||||
}}
|
||||
QScrollBar::add-line:vertical {{
|
||||
border: none;
|
||||
background: {_scroll_bar_btn_color};
|
||||
height: 20px;
|
||||
border-bottom-left-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
subcontrol-position: bottom;
|
||||
subcontrol-origin: margin;
|
||||
}}
|
||||
QScrollBar::sub-line:vertical {{
|
||||
border: none;
|
||||
background: {_scroll_bar_btn_color};
|
||||
height: 20px;
|
||||
border-top-left-radius: 4px;
|
||||
border-top-right-radius: 4px;
|
||||
subcontrol-position: top;
|
||||
subcontrol-origin: margin;
|
||||
}}
|
||||
QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical {{
|
||||
background: none;
|
||||
}}
|
||||
|
||||
QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {{
|
||||
background: none;
|
||||
}}
|
||||
# STYLE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
style = '''
|
||||
/* /////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
QTableWidget */
|
||||
|
||||
QTableWidget {{
|
||||
background-color: {_bg_color};
|
||||
padding: 5px;
|
||||
border-radius: {_radius}px;
|
||||
gridline-color: {_grid_line_color};
|
||||
color: {_color};
|
||||
}}
|
||||
QTableWidget::item{{
|
||||
border-color: none;
|
||||
padding-left: 5px;
|
||||
padding-right: 5px;
|
||||
gridline-color: rgb(44, 49, 60);
|
||||
border-bottom: 1px solid {_bottom_line_color};
|
||||
}}
|
||||
QTableWidget::item:selected{{
|
||||
background-color: {_selection_color};
|
||||
}}
|
||||
QHeaderView::section{{
|
||||
background-color: rgb(33, 37, 43);
|
||||
max-width: 30px;
|
||||
border: 1px solid rgb(44, 49, 58);
|
||||
border-style: none;
|
||||
border-bottom: 1px solid rgb(44, 49, 60);
|
||||
border-right: 1px solid rgb(44, 49, 60);
|
||||
}}
|
||||
QTableWidget::horizontalHeader {{
|
||||
background-color: rgb(33, 37, 43);
|
||||
}}
|
||||
QTableWidget QTableCornerButton::section {{
|
||||
border: none;
|
||||
background-color: {_header_horizontal_color};
|
||||
padding: 3px;
|
||||
border-top-left-radius: {_radius}px;
|
||||
}}
|
||||
QHeaderView::section:horizontal
|
||||
{{
|
||||
border: none;
|
||||
background-color: {_header_horizontal_color};
|
||||
padding: 3px;
|
||||
}}
|
||||
QHeaderView::section:vertical
|
||||
{{
|
||||
border: none;
|
||||
background-color: {_header_vertical_color};
|
||||
padding-left: 5px;
|
||||
padding-right: 5px;
|
||||
border-bottom: 1px solid {_bottom_line_color};
|
||||
margin-bottom: 1px;
|
||||
}}
|
||||
|
||||
|
||||
/* /////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
ScrollBars */
|
||||
QScrollBar:horizontal {{
|
||||
border: none;
|
||||
background: {_scroll_bar_bg_color};
|
||||
height: 8px;
|
||||
margin: 0px 21px 0 21px;
|
||||
border-radius: 0px;
|
||||
}}
|
||||
QScrollBar::handle:horizontal {{
|
||||
background: {_context_color};
|
||||
min-width: 25px;
|
||||
border-radius: 4px
|
||||
}}
|
||||
QScrollBar::add-line:horizontal {{
|
||||
border: none;
|
||||
background: {_scroll_bar_btn_color};
|
||||
width: 20px;
|
||||
border-top-right-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
subcontrol-position: right;
|
||||
subcontrol-origin: margin;
|
||||
}}
|
||||
QScrollBar::sub-line:horizontal {{
|
||||
border: none;
|
||||
background: {_scroll_bar_btn_color};
|
||||
width: 20px;
|
||||
border-top-left-radius: 4px;
|
||||
border-bottom-left-radius: 4px;
|
||||
subcontrol-position: left;
|
||||
subcontrol-origin: margin;
|
||||
}}
|
||||
QScrollBar::up-arrow:horizontal, QScrollBar::down-arrow:horizontal
|
||||
{{
|
||||
background: none;
|
||||
}}
|
||||
QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal
|
||||
{{
|
||||
background: none;
|
||||
}}
|
||||
QScrollBar:vertical {{
|
||||
border: none;
|
||||
background: {_scroll_bar_bg_color};
|
||||
width: 8px;
|
||||
margin: 21px 0 21px 0;
|
||||
border-radius: 0px;
|
||||
}}
|
||||
QScrollBar::handle:vertical {{
|
||||
background: {_context_color};
|
||||
min-height: 25px;
|
||||
border-radius: 4px
|
||||
}}
|
||||
QScrollBar::add-line:vertical {{
|
||||
border: none;
|
||||
background: {_scroll_bar_btn_color};
|
||||
height: 20px;
|
||||
border-bottom-left-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
subcontrol-position: bottom;
|
||||
subcontrol-origin: margin;
|
||||
}}
|
||||
QScrollBar::sub-line:vertical {{
|
||||
border: none;
|
||||
background: {_scroll_bar_btn_color};
|
||||
height: 20px;
|
||||
border-top-left-radius: 4px;
|
||||
border-top-right-radius: 4px;
|
||||
subcontrol-position: top;
|
||||
subcontrol-origin: margin;
|
||||
}}
|
||||
QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical {{
|
||||
background: none;
|
||||
}}
|
||||
|
||||
QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {{
|
||||
background: none;
|
||||
}}
|
||||
'''
|
||||
@@ -1,21 +1,21 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# PY TITLE BAR
|
||||
# Top bar with move application, maximize, restore, minimize,
|
||||
# close buttons and extra buttons
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# PY TITLE BAR
|
||||
# Top bar with move application, maximize, restore, minimize,
|
||||
# close buttons and extra buttons
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_title_bar import PyTitleBar
|
||||
@@ -1,35 +1,35 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# CUSTOM LEFT MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyDiv(QWidget):
|
||||
def __init__(self, color):
|
||||
super().__init__()
|
||||
|
||||
self.layout = QHBoxLayout(self)
|
||||
self.layout.setContentsMargins(0,5,0,5)
|
||||
self.frame_line = QFrame()
|
||||
self.frame_line.setStyleSheet(f"background: {color};")
|
||||
self.frame_line.setMaximumWidth(1)
|
||||
self.frame_line.setMinimumWidth(1)
|
||||
self.layout.addWidget(self.frame_line)
|
||||
self.setMaximumWidth(20)
|
||||
self.setMinimumWidth(20)
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# CUSTOM LEFT MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyDiv(QWidget):
|
||||
def __init__(self, color):
|
||||
super().__init__()
|
||||
|
||||
self.layout = QHBoxLayout(self)
|
||||
self.layout.setContentsMargins(0,5,0,5)
|
||||
self.frame_line = QFrame()
|
||||
self.frame_line.setStyleSheet(f"background: {color};")
|
||||
self.frame_line.setMaximumWidth(1)
|
||||
self.frame_line.setMinimumWidth(1)
|
||||
self.layout.addWidget(self.frame_line)
|
||||
self.setMaximumWidth(20)
|
||||
self.setMinimumWidth(20)
|
||||
|
||||
@@ -1,346 +1,346 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# IMPORT FUNCTIONS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from gui.core.functions import *
|
||||
|
||||
# IMPORT SETTINGS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from gui.core.json_settings import Settings
|
||||
|
||||
# IMPORT DIV
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_div import PyDiv
|
||||
|
||||
# IMPORT BUTTON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_title_button import PyTitleButton
|
||||
|
||||
# GLOBALS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
_is_maximized = False
|
||||
_old_size = QSize()
|
||||
|
||||
# PY TITLE BAR
|
||||
# Top bar with move application, maximize, restore, minimize,
|
||||
# close buttons and extra buttons
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyTitleBar(QWidget):
|
||||
# SIGNALS
|
||||
clicked = Signal(object)
|
||||
released = Signal(object)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
parent,
|
||||
app_parent,
|
||||
logo_image = "logo_top_100x22.svg",
|
||||
logo_width = 100,
|
||||
buttons = None,
|
||||
dark_one = "#1b1e23",
|
||||
bg_color = "#343b48",
|
||||
div_color = "#3c4454",
|
||||
btn_bg_color = "#343b48",
|
||||
btn_bg_color_hover = "#3c4454",
|
||||
btn_bg_color_pressed = "#2c313c",
|
||||
icon_color = "#c3ccdf",
|
||||
icon_color_hover = "#dce1ec",
|
||||
icon_color_pressed = "#edf0f5",
|
||||
icon_color_active = "#f5f6f9",
|
||||
context_color = "#6c99f4",
|
||||
text_foreground = "#8a95aa",
|
||||
radius = 8,
|
||||
font_family = "Segoe UI",
|
||||
title_size = 10,
|
||||
is_custom_title_bar = True,
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
settings = Settings()
|
||||
self.settings = settings.items
|
||||
|
||||
# PARAMETERS
|
||||
self._logo_image = logo_image
|
||||
self._dark_one = dark_one
|
||||
self._bg_color = bg_color
|
||||
self._div_color = div_color
|
||||
self._parent = parent
|
||||
self._app_parent = app_parent
|
||||
self._btn_bg_color = btn_bg_color
|
||||
self._btn_bg_color_hover = btn_bg_color_hover
|
||||
self._btn_bg_color_pressed = btn_bg_color_pressed
|
||||
self._context_color = context_color
|
||||
self._icon_color = icon_color
|
||||
self._icon_color_hover = icon_color_hover
|
||||
self._icon_color_pressed = icon_color_pressed
|
||||
self._icon_color_active = icon_color_active
|
||||
self._font_family = font_family
|
||||
self._title_size = title_size
|
||||
self._text_foreground = text_foreground
|
||||
self._is_custom_title_bar = is_custom_title_bar
|
||||
|
||||
# SETUP UI
|
||||
self.setup_ui()
|
||||
|
||||
# ADD BG COLOR
|
||||
self.bg.setStyleSheet(f"background-color: {bg_color}; border-radius: {radius}px;")
|
||||
|
||||
# SET LOGO AND WIDTH
|
||||
self.top_logo.setMinimumWidth(logo_width)
|
||||
self.top_logo.setMaximumWidth(logo_width)
|
||||
#self.top_logo.setPixmap(Functions.set_svg_image(logo_image))
|
||||
|
||||
# MOVE WINDOW / MAXIMIZE / RESTORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def moveWindow(event):
|
||||
# IF MAXIMIZED CHANGE TO NORMAL
|
||||
if parent.isMaximized():
|
||||
self.maximize_restore()
|
||||
#self.resize(_old_size)
|
||||
curso_x = parent.pos().x()
|
||||
curso_y = event.globalPos().y() - QCursor.pos().y()
|
||||
parent.move(curso_x, curso_y)
|
||||
# MOVE WINDOW
|
||||
if event.buttons() == Qt.LeftButton:
|
||||
parent.move(parent.pos() + event.globalPos() - parent.dragPos)
|
||||
parent.dragPos = event.globalPos()
|
||||
event.accept()
|
||||
|
||||
# MOVE APP WIDGETS
|
||||
if is_custom_title_bar:
|
||||
self.top_logo.mouseMoveEvent = moveWindow
|
||||
self.div_1.mouseMoveEvent = moveWindow
|
||||
self.title_label.mouseMoveEvent = moveWindow
|
||||
self.div_2.mouseMoveEvent = moveWindow
|
||||
self.div_3.mouseMoveEvent = moveWindow
|
||||
|
||||
# MAXIMIZE / RESTORE
|
||||
if is_custom_title_bar:
|
||||
self.top_logo.mouseDoubleClickEvent = self.maximize_restore
|
||||
self.div_1.mouseDoubleClickEvent = self.maximize_restore
|
||||
self.title_label.mouseDoubleClickEvent = self.maximize_restore
|
||||
self.div_2.mouseDoubleClickEvent = self.maximize_restore
|
||||
|
||||
# ADD WIDGETS TO TITLE BAR
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self.bg_layout.addWidget(self.top_logo)
|
||||
self.bg_layout.addWidget(self.div_1)
|
||||
self.bg_layout.addWidget(self.title_label)
|
||||
self.bg_layout.addWidget(self.div_2)
|
||||
|
||||
# ADD BUTTONS BUTTONS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
# Functions
|
||||
self.minimize_button.released.connect(lambda: parent.showMinimized())
|
||||
self.maximize_restore_button.released.connect(lambda: self.maximize_restore())
|
||||
self.close_button.released.connect(lambda: parent.close())
|
||||
|
||||
# Extra BTNs layout
|
||||
self.bg_layout.addLayout(self.custom_buttons_layout)
|
||||
|
||||
# ADD Buttons
|
||||
if is_custom_title_bar:
|
||||
self.bg_layout.addWidget(self.minimize_button)
|
||||
self.bg_layout.addWidget(self.maximize_restore_button)
|
||||
self.bg_layout.addWidget(self.close_button)
|
||||
|
||||
# ADD BUTTONS TO TITLE BAR
|
||||
# Add btns and emit signals
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def add_menus(self, parameters):
|
||||
if parameters != None and len(parameters) > 0:
|
||||
for parameter in parameters:
|
||||
_btn_icon = Functions.set_svg_icon(parameter['btn_icon'])
|
||||
_btn_id = parameter['btn_id']
|
||||
_btn_tooltip = parameter['btn_tooltip']
|
||||
_is_active = parameter['is_active']
|
||||
|
||||
self.menu = PyTitleButton(
|
||||
self._parent,
|
||||
self._app_parent,
|
||||
btn_id = _btn_id,
|
||||
tooltip_text = _btn_tooltip,
|
||||
dark_one = self._dark_one,
|
||||
bg_color = self._bg_color,
|
||||
bg_color_hover = self._btn_bg_color_hover,
|
||||
bg_color_pressed = self._btn_bg_color_pressed,
|
||||
icon_color = self._icon_color,
|
||||
icon_color_hover = self._icon_color_active,
|
||||
icon_color_pressed = self._icon_color_pressed,
|
||||
icon_color_active = self._icon_color_active,
|
||||
context_color = self._context_color,
|
||||
text_foreground = self._text_foreground,
|
||||
icon_path = _btn_icon,
|
||||
is_active = _is_active
|
||||
)
|
||||
self.menu.clicked.connect(self.btn_clicked)
|
||||
self.menu.released.connect(self.btn_released)
|
||||
|
||||
# ADD TO LAYOUT
|
||||
self.custom_buttons_layout.addWidget(self.menu)
|
||||
|
||||
# ADD DIV
|
||||
if self._is_custom_title_bar:
|
||||
self.custom_buttons_layout.addWidget(self.div_3)
|
||||
|
||||
# TITLE BAR MENU EMIT SIGNALS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def btn_clicked(self):
|
||||
self.clicked.emit(self.menu)
|
||||
|
||||
def btn_released(self):
|
||||
self.released.emit(self.menu)
|
||||
|
||||
# SET TITLE BAR TEXT
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def set_title(self, title):
|
||||
self.title_label.setText(title)
|
||||
|
||||
# MAXIMIZE / RESTORE
|
||||
# maximize and restore parent window
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def maximize_restore(self, e = None):
|
||||
global _is_maximized
|
||||
global _old_size
|
||||
|
||||
# CHANGE UI AND RESIZE GRIP
|
||||
def change_ui():
|
||||
if _is_maximized:
|
||||
self._parent.ui.central_widget_layout.setContentsMargins(0,0,0,0)
|
||||
self._parent.ui.window.set_stylesheet(border_radius = 0, border_size = 0)
|
||||
self.maximize_restore_button.set_icon(
|
||||
Functions.set_svg_icon("icon_restore.svg")
|
||||
)
|
||||
else:
|
||||
self._parent.ui.central_widget_layout.setContentsMargins(10,10,10,10)
|
||||
self._parent.ui.window.set_stylesheet(border_radius = 10, border_size = 2)
|
||||
self.maximize_restore_button.set_icon(
|
||||
Functions.set_svg_icon("icon_maximize.svg")
|
||||
)
|
||||
|
||||
# CHECK EVENT
|
||||
if self._parent.isMaximized():
|
||||
_is_maximized = False
|
||||
self._parent.showNormal()
|
||||
change_ui()
|
||||
else:
|
||||
_is_maximized = True
|
||||
_old_size = QSize(self._parent.width(), self._parent.height())
|
||||
self._parent.showMaximized()
|
||||
change_ui()
|
||||
|
||||
# SETUP APP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def setup_ui(self):
|
||||
# ADD MENU LAYOUT
|
||||
self.title_bar_layout = QVBoxLayout(self)
|
||||
self.title_bar_layout.setContentsMargins(0,0,0,0)
|
||||
|
||||
# ADD BG
|
||||
self.bg = QFrame()
|
||||
|
||||
# ADD BG LAYOUT
|
||||
self.bg_layout = QHBoxLayout(self.bg)
|
||||
self.bg_layout.setContentsMargins(10,0,5,0)
|
||||
self.bg_layout.setSpacing(0)
|
||||
|
||||
# DIVS
|
||||
self.div_1 = PyDiv(self._div_color)
|
||||
self.div_2 = PyDiv(self._div_color)
|
||||
self.div_3 = PyDiv(self._div_color)
|
||||
|
||||
# LEFT FRAME WITH MOVE APP
|
||||
self.top_logo = QLabel()
|
||||
self.top_logo_layout = QVBoxLayout(self.top_logo)
|
||||
self.top_logo_layout.setContentsMargins(0,0,0,0)
|
||||
self.logo_svg = QSvgWidget()
|
||||
self.logo_svg.load(Functions.set_svg_image(self._logo_image))
|
||||
self.top_logo_layout.addWidget(self.logo_svg, Qt.AlignCenter, Qt.AlignCenter)
|
||||
|
||||
# TITLE LABEL
|
||||
self.title_label = QLabel()
|
||||
self.title_label.setAlignment(Qt.AlignVCenter)
|
||||
self.title_label.setStyleSheet(f'font: {self._title_size}pt "{self._font_family}"')
|
||||
|
||||
# CUSTOM BUTTONS LAYOUT
|
||||
self.custom_buttons_layout = QHBoxLayout()
|
||||
self.custom_buttons_layout.setContentsMargins(0,0,0,0)
|
||||
self.custom_buttons_layout.setSpacing(3)
|
||||
|
||||
# MINIMIZE BUTTON
|
||||
self.minimize_button = PyTitleButton(
|
||||
self._parent,
|
||||
self._app_parent,
|
||||
tooltip_text = "Close app",
|
||||
dark_one = self._dark_one,
|
||||
bg_color = self._btn_bg_color,
|
||||
bg_color_hover = self._btn_bg_color_hover,
|
||||
bg_color_pressed = self._btn_bg_color_pressed,
|
||||
icon_color = self._icon_color,
|
||||
icon_color_hover = self._icon_color_hover,
|
||||
icon_color_pressed = self._icon_color_pressed,
|
||||
icon_color_active = self._icon_color_active,
|
||||
context_color = self._context_color,
|
||||
text_foreground = self._text_foreground,
|
||||
radius = 6,
|
||||
icon_path = Functions.set_svg_icon("icon_minimize.svg")
|
||||
)
|
||||
|
||||
# MAXIMIZE / RESTORE BUTTON
|
||||
self.maximize_restore_button = PyTitleButton(
|
||||
self._parent,
|
||||
self._app_parent,
|
||||
tooltip_text = "Maximize app",
|
||||
dark_one = self._dark_one,
|
||||
bg_color = self._btn_bg_color,
|
||||
bg_color_hover = self._btn_bg_color_hover,
|
||||
bg_color_pressed = self._btn_bg_color_pressed,
|
||||
icon_color = self._icon_color,
|
||||
icon_color_hover = self._icon_color_hover,
|
||||
icon_color_pressed = self._icon_color_pressed,
|
||||
icon_color_active = self._icon_color_active,
|
||||
context_color = self._context_color,
|
||||
text_foreground = self._text_foreground,
|
||||
radius = 6,
|
||||
icon_path = Functions.set_svg_icon("icon_maximize.svg")
|
||||
)
|
||||
|
||||
# CLOSE BUTTON
|
||||
self.close_button = PyTitleButton(
|
||||
self._parent,
|
||||
self._app_parent,
|
||||
tooltip_text = "Close app",
|
||||
dark_one = self._dark_one,
|
||||
bg_color = self._btn_bg_color,
|
||||
bg_color_hover = self._btn_bg_color_hover,
|
||||
bg_color_pressed = self._context_color,
|
||||
icon_color = self._icon_color,
|
||||
icon_color_hover = self._icon_color_hover,
|
||||
icon_color_pressed = self._icon_color_active,
|
||||
icon_color_active = self._icon_color_active,
|
||||
context_color = self._context_color,
|
||||
text_foreground = self._text_foreground,
|
||||
radius = 6,
|
||||
icon_path = Functions.set_svg_icon("icon_close.svg")
|
||||
)
|
||||
|
||||
# ADD TO LAYOUT
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# IMPORT FUNCTIONS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from gui.core.functions import *
|
||||
|
||||
# IMPORT SETTINGS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from gui.core.json_settings import Settings
|
||||
|
||||
# IMPORT DIV
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_div import PyDiv
|
||||
|
||||
# IMPORT BUTTON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_title_button import PyTitleButton
|
||||
|
||||
# GLOBALS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
_is_maximized = False
|
||||
_old_size = QSize()
|
||||
|
||||
# PY TITLE BAR
|
||||
# Top bar with move application, maximize, restore, minimize,
|
||||
# close buttons and extra buttons
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyTitleBar(QWidget):
|
||||
# SIGNALS
|
||||
clicked = Signal(object)
|
||||
released = Signal(object)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
parent,
|
||||
app_parent,
|
||||
logo_image = "logo_top_100x22.svg",
|
||||
logo_width = 100,
|
||||
buttons = None,
|
||||
dark_one = "#1b1e23",
|
||||
bg_color = "#343b48",
|
||||
div_color = "#3c4454",
|
||||
btn_bg_color = "#343b48",
|
||||
btn_bg_color_hover = "#3c4454",
|
||||
btn_bg_color_pressed = "#2c313c",
|
||||
icon_color = "#c3ccdf",
|
||||
icon_color_hover = "#dce1ec",
|
||||
icon_color_pressed = "#edf0f5",
|
||||
icon_color_active = "#f5f6f9",
|
||||
context_color = "#6c99f4",
|
||||
text_foreground = "#8a95aa",
|
||||
radius = 8,
|
||||
font_family = "Segoe UI",
|
||||
title_size = 10,
|
||||
is_custom_title_bar = True,
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
settings = Settings()
|
||||
self.settings = settings.items
|
||||
|
||||
# PARAMETERS
|
||||
self._logo_image = logo_image
|
||||
self._dark_one = dark_one
|
||||
self._bg_color = bg_color
|
||||
self._div_color = div_color
|
||||
self._parent = parent
|
||||
self._app_parent = app_parent
|
||||
self._btn_bg_color = btn_bg_color
|
||||
self._btn_bg_color_hover = btn_bg_color_hover
|
||||
self._btn_bg_color_pressed = btn_bg_color_pressed
|
||||
self._context_color = context_color
|
||||
self._icon_color = icon_color
|
||||
self._icon_color_hover = icon_color_hover
|
||||
self._icon_color_pressed = icon_color_pressed
|
||||
self._icon_color_active = icon_color_active
|
||||
self._font_family = font_family
|
||||
self._title_size = title_size
|
||||
self._text_foreground = text_foreground
|
||||
self._is_custom_title_bar = is_custom_title_bar
|
||||
|
||||
# SETUP UI
|
||||
self.setup_ui()
|
||||
|
||||
# ADD BG COLOR
|
||||
self.bg.setStyleSheet(f"background-color: {bg_color}; border-radius: {radius}px;")
|
||||
|
||||
# SET LOGO AND WIDTH
|
||||
self.top_logo.setMinimumWidth(logo_width)
|
||||
self.top_logo.setMaximumWidth(logo_width)
|
||||
#self.top_logo.setPixmap(Functions.set_svg_image(logo_image))
|
||||
|
||||
# MOVE WINDOW / MAXIMIZE / RESTORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def moveWindow(event):
|
||||
# IF MAXIMIZED CHANGE TO NORMAL
|
||||
if parent.isMaximized():
|
||||
self.maximize_restore()
|
||||
#self.resize(_old_size)
|
||||
curso_x = parent.pos().x()
|
||||
curso_y = event.globalPos().y() - QCursor.pos().y()
|
||||
parent.move(curso_x, curso_y)
|
||||
# MOVE WINDOW
|
||||
if event.buttons() == Qt.LeftButton:
|
||||
parent.move(parent.pos() + event.globalPos() - parent.dragPos)
|
||||
parent.dragPos = event.globalPos()
|
||||
event.accept()
|
||||
|
||||
# MOVE APP WIDGETS
|
||||
if is_custom_title_bar:
|
||||
self.top_logo.mouseMoveEvent = moveWindow
|
||||
self.div_1.mouseMoveEvent = moveWindow
|
||||
self.title_label.mouseMoveEvent = moveWindow
|
||||
self.div_2.mouseMoveEvent = moveWindow
|
||||
self.div_3.mouseMoveEvent = moveWindow
|
||||
|
||||
# MAXIMIZE / RESTORE
|
||||
if is_custom_title_bar:
|
||||
self.top_logo.mouseDoubleClickEvent = self.maximize_restore
|
||||
self.div_1.mouseDoubleClickEvent = self.maximize_restore
|
||||
self.title_label.mouseDoubleClickEvent = self.maximize_restore
|
||||
self.div_2.mouseDoubleClickEvent = self.maximize_restore
|
||||
|
||||
# ADD WIDGETS TO TITLE BAR
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self.bg_layout.addWidget(self.top_logo)
|
||||
self.bg_layout.addWidget(self.div_1)
|
||||
self.bg_layout.addWidget(self.title_label)
|
||||
self.bg_layout.addWidget(self.div_2)
|
||||
|
||||
# ADD BUTTONS BUTTONS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
# Functions
|
||||
self.minimize_button.released.connect(lambda: parent.showMinimized())
|
||||
self.maximize_restore_button.released.connect(lambda: self.maximize_restore())
|
||||
self.close_button.released.connect(lambda: parent.close())
|
||||
|
||||
# Extra BTNs layout
|
||||
self.bg_layout.addLayout(self.custom_buttons_layout)
|
||||
|
||||
# ADD Buttons
|
||||
if is_custom_title_bar:
|
||||
self.bg_layout.addWidget(self.minimize_button)
|
||||
self.bg_layout.addWidget(self.maximize_restore_button)
|
||||
self.bg_layout.addWidget(self.close_button)
|
||||
|
||||
# ADD BUTTONS TO TITLE BAR
|
||||
# Add btns and emit signals
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def add_menus(self, parameters):
|
||||
if parameters != None and len(parameters) > 0:
|
||||
for parameter in parameters:
|
||||
_btn_icon = Functions.set_svg_icon(parameter['btn_icon'])
|
||||
_btn_id = parameter['btn_id']
|
||||
_btn_tooltip = parameter['btn_tooltip']
|
||||
_is_active = parameter['is_active']
|
||||
|
||||
self.menu = PyTitleButton(
|
||||
self._parent,
|
||||
self._app_parent,
|
||||
btn_id = _btn_id,
|
||||
tooltip_text = _btn_tooltip,
|
||||
dark_one = self._dark_one,
|
||||
bg_color = self._bg_color,
|
||||
bg_color_hover = self._btn_bg_color_hover,
|
||||
bg_color_pressed = self._btn_bg_color_pressed,
|
||||
icon_color = self._icon_color,
|
||||
icon_color_hover = self._icon_color_active,
|
||||
icon_color_pressed = self._icon_color_pressed,
|
||||
icon_color_active = self._icon_color_active,
|
||||
context_color = self._context_color,
|
||||
text_foreground = self._text_foreground,
|
||||
icon_path = _btn_icon,
|
||||
is_active = _is_active
|
||||
)
|
||||
self.menu.clicked.connect(self.btn_clicked)
|
||||
self.menu.released.connect(self.btn_released)
|
||||
|
||||
# ADD TO LAYOUT
|
||||
self.custom_buttons_layout.addWidget(self.menu)
|
||||
|
||||
# ADD DIV
|
||||
if self._is_custom_title_bar:
|
||||
self.custom_buttons_layout.addWidget(self.div_3)
|
||||
|
||||
# TITLE BAR MENU EMIT SIGNALS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def btn_clicked(self):
|
||||
self.clicked.emit(self.menu)
|
||||
|
||||
def btn_released(self):
|
||||
self.released.emit(self.menu)
|
||||
|
||||
# SET TITLE BAR TEXT
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def set_title(self, title):
|
||||
self.title_label.setText(title)
|
||||
|
||||
# MAXIMIZE / RESTORE
|
||||
# maximize and restore parent window
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def maximize_restore(self, e = None):
|
||||
global _is_maximized
|
||||
global _old_size
|
||||
|
||||
# CHANGE UI AND RESIZE GRIP
|
||||
def change_ui():
|
||||
if _is_maximized:
|
||||
self._parent.ui.central_widget_layout.setContentsMargins(0,0,0,0)
|
||||
self._parent.ui.window.set_stylesheet(border_radius = 0, border_size = 0)
|
||||
self.maximize_restore_button.set_icon(
|
||||
Functions.set_svg_icon("icon_restore.svg")
|
||||
)
|
||||
else:
|
||||
self._parent.ui.central_widget_layout.setContentsMargins(10,10,10,10)
|
||||
self._parent.ui.window.set_stylesheet(border_radius = 10, border_size = 2)
|
||||
self.maximize_restore_button.set_icon(
|
||||
Functions.set_svg_icon("icon_maximize.svg")
|
||||
)
|
||||
|
||||
# CHECK EVENT
|
||||
if self._parent.isMaximized():
|
||||
_is_maximized = False
|
||||
self._parent.showNormal()
|
||||
change_ui()
|
||||
else:
|
||||
_is_maximized = True
|
||||
_old_size = QSize(self._parent.width(), self._parent.height())
|
||||
self._parent.showMaximized()
|
||||
change_ui()
|
||||
|
||||
# SETUP APP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def setup_ui(self):
|
||||
# ADD MENU LAYOUT
|
||||
self.title_bar_layout = QVBoxLayout(self)
|
||||
self.title_bar_layout.setContentsMargins(0,0,0,0)
|
||||
|
||||
# ADD BG
|
||||
self.bg = QFrame()
|
||||
|
||||
# ADD BG LAYOUT
|
||||
self.bg_layout = QHBoxLayout(self.bg)
|
||||
self.bg_layout.setContentsMargins(10,0,5,0)
|
||||
self.bg_layout.setSpacing(0)
|
||||
|
||||
# DIVS
|
||||
self.div_1 = PyDiv(self._div_color)
|
||||
self.div_2 = PyDiv(self._div_color)
|
||||
self.div_3 = PyDiv(self._div_color)
|
||||
|
||||
# LEFT FRAME WITH MOVE APP
|
||||
self.top_logo = QLabel()
|
||||
self.top_logo_layout = QVBoxLayout(self.top_logo)
|
||||
self.top_logo_layout.setContentsMargins(0,0,0,0)
|
||||
self.logo_svg = QSvgWidget()
|
||||
self.logo_svg.load(Functions.set_svg_image(self._logo_image))
|
||||
self.top_logo_layout.addWidget(self.logo_svg, Qt.AlignCenter, Qt.AlignCenter)
|
||||
|
||||
# TITLE LABEL
|
||||
self.title_label = QLabel()
|
||||
self.title_label.setAlignment(Qt.AlignVCenter)
|
||||
self.title_label.setStyleSheet(f'font: {self._title_size}pt "{self._font_family}"')
|
||||
|
||||
# CUSTOM BUTTONS LAYOUT
|
||||
self.custom_buttons_layout = QHBoxLayout()
|
||||
self.custom_buttons_layout.setContentsMargins(0,0,0,0)
|
||||
self.custom_buttons_layout.setSpacing(3)
|
||||
|
||||
# MINIMIZE BUTTON
|
||||
self.minimize_button = PyTitleButton(
|
||||
self._parent,
|
||||
self._app_parent,
|
||||
tooltip_text = "Close app",
|
||||
dark_one = self._dark_one,
|
||||
bg_color = self._btn_bg_color,
|
||||
bg_color_hover = self._btn_bg_color_hover,
|
||||
bg_color_pressed = self._btn_bg_color_pressed,
|
||||
icon_color = self._icon_color,
|
||||
icon_color_hover = self._icon_color_hover,
|
||||
icon_color_pressed = self._icon_color_pressed,
|
||||
icon_color_active = self._icon_color_active,
|
||||
context_color = self._context_color,
|
||||
text_foreground = self._text_foreground,
|
||||
radius = 6,
|
||||
icon_path = Functions.set_svg_icon("icon_minimize.svg")
|
||||
)
|
||||
|
||||
# MAXIMIZE / RESTORE BUTTON
|
||||
self.maximize_restore_button = PyTitleButton(
|
||||
self._parent,
|
||||
self._app_parent,
|
||||
tooltip_text = "Maximize app",
|
||||
dark_one = self._dark_one,
|
||||
bg_color = self._btn_bg_color,
|
||||
bg_color_hover = self._btn_bg_color_hover,
|
||||
bg_color_pressed = self._btn_bg_color_pressed,
|
||||
icon_color = self._icon_color,
|
||||
icon_color_hover = self._icon_color_hover,
|
||||
icon_color_pressed = self._icon_color_pressed,
|
||||
icon_color_active = self._icon_color_active,
|
||||
context_color = self._context_color,
|
||||
text_foreground = self._text_foreground,
|
||||
radius = 6,
|
||||
icon_path = Functions.set_svg_icon("icon_maximize.svg")
|
||||
)
|
||||
|
||||
# CLOSE BUTTON
|
||||
self.close_button = PyTitleButton(
|
||||
self._parent,
|
||||
self._app_parent,
|
||||
tooltip_text = "Close app",
|
||||
dark_one = self._dark_one,
|
||||
bg_color = self._btn_bg_color,
|
||||
bg_color_hover = self._btn_bg_color_hover,
|
||||
bg_color_pressed = self._context_color,
|
||||
icon_color = self._icon_color,
|
||||
icon_color_hover = self._icon_color_hover,
|
||||
icon_color_pressed = self._icon_color_active,
|
||||
icon_color_active = self._icon_color_active,
|
||||
context_color = self._context_color,
|
||||
text_foreground = self._text_foreground,
|
||||
radius = 6,
|
||||
icon_path = Functions.set_svg_icon("icon_close.svg")
|
||||
)
|
||||
|
||||
# ADD TO LAYOUT
|
||||
self.title_bar_layout.addWidget(self.bg)
|
||||
@@ -1,271 +1,271 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# PY TITLE BUTTON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyTitleButton(QPushButton):
|
||||
def __init__(
|
||||
self,
|
||||
parent,
|
||||
app_parent = None,
|
||||
tooltip_text = "",
|
||||
btn_id = None,
|
||||
width = 30,
|
||||
height = 30,
|
||||
radius = 8,
|
||||
bg_color = "#343b48",
|
||||
bg_color_hover = "#3c4454",
|
||||
bg_color_pressed = "#2c313c",
|
||||
icon_color = "#c3ccdf",
|
||||
icon_color_hover = "#dce1ec",
|
||||
icon_color_pressed = "#edf0f5",
|
||||
icon_color_active = "#f5f6f9",
|
||||
icon_path = "no_icon.svg",
|
||||
dark_one = "#1b1e23",
|
||||
context_color = "#568af2",
|
||||
text_foreground = "#8a95aa",
|
||||
is_active = False
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
# SET DEFAULT PARAMETERS
|
||||
self.setFixedSize(width, height)
|
||||
self.setCursor(Qt.PointingHandCursor)
|
||||
self.setObjectName(btn_id)
|
||||
|
||||
# PROPERTIES
|
||||
self._bg_color = bg_color
|
||||
self._bg_color_hover = bg_color_hover
|
||||
self._bg_color_pressed = bg_color_pressed
|
||||
self._icon_color = icon_color
|
||||
self._icon_color_hover = icon_color_hover
|
||||
self._icon_color_pressed = icon_color_pressed
|
||||
self._icon_color_active = icon_color_active
|
||||
self._context_color = context_color
|
||||
self._top_margin = self.height() + 6
|
||||
self._is_active = is_active
|
||||
# Set Parameters
|
||||
self._set_bg_color = bg_color
|
||||
self._set_icon_path = icon_path
|
||||
self._set_icon_color = icon_color
|
||||
self._set_border_radius = radius
|
||||
# Parent
|
||||
self._parent = parent
|
||||
self._app_parent = app_parent
|
||||
|
||||
# TOOLTIP
|
||||
self._tooltip_text = tooltip_text
|
||||
self._tooltip = _ToolTip(
|
||||
app_parent,
|
||||
tooltip_text,
|
||||
dark_one,
|
||||
context_color,
|
||||
text_foreground
|
||||
)
|
||||
self._tooltip.hide()
|
||||
|
||||
# SET ACTIVE MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def set_active(self, is_active):
|
||||
self._is_active = is_active
|
||||
self.repaint()
|
||||
|
||||
# RETURN IF IS ACTIVE MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def is_active(self):
|
||||
return self._is_active
|
||||
|
||||
# PAINT EVENT
|
||||
# painting the button and the icon
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def paintEvent(self, event):
|
||||
# PAINTER
|
||||
paint = QPainter()
|
||||
paint.begin(self)
|
||||
paint.setRenderHint(QPainter.RenderHint.Antialiasing)
|
||||
|
||||
if self._is_active:
|
||||
# BRUSH
|
||||
brush = QBrush(QColor(self._context_color))
|
||||
else:
|
||||
# BRUSH
|
||||
brush = QBrush(QColor(self._set_bg_color))
|
||||
|
||||
# CREATE RECTANGLE
|
||||
rect = QRect(0, 0, self.width(), self.height())
|
||||
paint.setPen(Qt.NoPen)
|
||||
paint.setBrush(brush)
|
||||
paint.drawRoundedRect(
|
||||
rect,
|
||||
self._set_border_radius,
|
||||
self._set_border_radius
|
||||
)
|
||||
|
||||
# DRAW ICONS
|
||||
self.icon_paint(paint, self._set_icon_path, rect)
|
||||
|
||||
# END PAINTER
|
||||
paint.end()
|
||||
|
||||
# CHANGE STYLES
|
||||
# Functions with custom styles
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def change_style(self, event):
|
||||
if event == QEvent.Enter:
|
||||
self._set_bg_color = self._bg_color_hover
|
||||
self._set_icon_color = self._icon_color_hover
|
||||
self.repaint()
|
||||
elif event == QEvent.Leave:
|
||||
self._set_bg_color = self._bg_color
|
||||
self._set_icon_color = self._icon_color
|
||||
self.repaint()
|
||||
elif event == QEvent.MouseButtonPress:
|
||||
self._set_bg_color = self._bg_color_pressed
|
||||
self._set_icon_color = self._icon_color_pressed
|
||||
self.repaint()
|
||||
elif event == QEvent.MouseButtonRelease:
|
||||
self._set_bg_color = self._bg_color_hover
|
||||
self._set_icon_color = self._icon_color_hover
|
||||
self.repaint()
|
||||
|
||||
# MOUSE OVER
|
||||
# Event triggered when the mouse is over the BTN
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def enterEvent(self, event):
|
||||
self.change_style(QEvent.Enter)
|
||||
self.move_tooltip()
|
||||
self._tooltip.show()
|
||||
|
||||
# MOUSE LEAVE
|
||||
# Event fired when the mouse leaves the BTN
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def leaveEvent(self, event):
|
||||
self.change_style(QEvent.Leave)
|
||||
self.move_tooltip()
|
||||
self._tooltip.hide()
|
||||
|
||||
# MOUSE PRESS
|
||||
# Event triggered when the left button is pressed
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def mousePressEvent(self, event):
|
||||
if event.button() == Qt.LeftButton:
|
||||
self.change_style(QEvent.MouseButtonPress)
|
||||
# SET FOCUS
|
||||
self.setFocus()
|
||||
# EMIT SIGNAL
|
||||
return self.clicked.emit()
|
||||
|
||||
# MOUSE RELEASED
|
||||
# Event triggered after the mouse button is released
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def mouseReleaseEvent(self, event):
|
||||
if event.button() == Qt.LeftButton:
|
||||
self.change_style(QEvent.MouseButtonRelease)
|
||||
# EMIT SIGNAL
|
||||
return self.released.emit()
|
||||
|
||||
# DRAW ICON WITH COLORS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def icon_paint(self, qp, image, rect):
|
||||
icon = QPixmap(image)
|
||||
painter = QPainter(icon)
|
||||
painter.setCompositionMode(QPainter.CompositionMode_SourceIn)
|
||||
if self._is_active:
|
||||
painter.fillRect(icon.rect(), self._icon_color_active)
|
||||
else:
|
||||
painter.fillRect(icon.rect(), self._set_icon_color)
|
||||
qp.drawPixmap(
|
||||
(rect.width() - icon.width()) / 2,
|
||||
(rect.height() - icon.height()) / 2,
|
||||
icon
|
||||
)
|
||||
painter.end()
|
||||
|
||||
# SET ICON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def set_icon(self, icon_path):
|
||||
self._set_icon_path = icon_path
|
||||
self.repaint()
|
||||
|
||||
# MOVE TOOLTIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def move_tooltip(self):
|
||||
# GET MAIN WINDOW PARENT
|
||||
gp = self.mapToGlobal(QPoint(0, 0))
|
||||
|
||||
# SET WIDGET TO GET POSTION
|
||||
# Return absolute position of widget inside app
|
||||
pos = self._parent.mapFromGlobal(gp)
|
||||
|
||||
# FORMAT POSITION
|
||||
# Adjust tooltip position with offset
|
||||
pos_x = (pos.x() - self._tooltip.width()) + self.width() + 5
|
||||
pos_y = pos.y() + self._top_margin
|
||||
|
||||
# SET POSITION TO WIDGET
|
||||
# Move tooltip position
|
||||
self._tooltip.move(pos_x, pos_y)
|
||||
|
||||
# TOOLTIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class _ToolTip(QLabel):
|
||||
# TOOLTIP / LABEL StyleSheet
|
||||
style_tooltip = """
|
||||
QLabel {{
|
||||
background-color: {_dark_one};
|
||||
color: {_text_foreground};
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
border-radius: 17px;
|
||||
border: 0px solid transparent;
|
||||
border-right: 3px solid {_context_color};
|
||||
font: 800 9pt "Segoe UI";
|
||||
}}
|
||||
"""
|
||||
def __init__(
|
||||
self,
|
||||
parent,
|
||||
tooltip,
|
||||
dark_one,
|
||||
context_color,
|
||||
text_foreground
|
||||
):
|
||||
QLabel.__init__(self)
|
||||
|
||||
# LABEL SETUP
|
||||
style = self.style_tooltip.format(
|
||||
_dark_one = dark_one,
|
||||
_context_color = context_color,
|
||||
_text_foreground = text_foreground
|
||||
)
|
||||
self.setObjectName(u"label_tooltip")
|
||||
self.setStyleSheet(style)
|
||||
self.setMinimumHeight(34)
|
||||
self.setParent(parent)
|
||||
self.setText(tooltip)
|
||||
self.adjustSize()
|
||||
|
||||
# SET DROP SHADOW
|
||||
self.shadow = QGraphicsDropShadowEffect(self)
|
||||
self.shadow.setBlurRadius(30)
|
||||
self.shadow.setXOffset(0)
|
||||
self.shadow.setYOffset(0)
|
||||
self.shadow.setColor(QColor(0, 0, 0, 80))
|
||||
self.setGraphicsEffect(self.shadow)
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# PY TITLE BUTTON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyTitleButton(QPushButton):
|
||||
def __init__(
|
||||
self,
|
||||
parent,
|
||||
app_parent = None,
|
||||
tooltip_text = "",
|
||||
btn_id = None,
|
||||
width = 30,
|
||||
height = 30,
|
||||
radius = 8,
|
||||
bg_color = "#343b48",
|
||||
bg_color_hover = "#3c4454",
|
||||
bg_color_pressed = "#2c313c",
|
||||
icon_color = "#c3ccdf",
|
||||
icon_color_hover = "#dce1ec",
|
||||
icon_color_pressed = "#edf0f5",
|
||||
icon_color_active = "#f5f6f9",
|
||||
icon_path = "no_icon.svg",
|
||||
dark_one = "#1b1e23",
|
||||
context_color = "#568af2",
|
||||
text_foreground = "#8a95aa",
|
||||
is_active = False
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
# SET DEFAULT PARAMETERS
|
||||
self.setFixedSize(width, height)
|
||||
self.setCursor(Qt.PointingHandCursor)
|
||||
self.setObjectName(btn_id)
|
||||
|
||||
# PROPERTIES
|
||||
self._bg_color = bg_color
|
||||
self._bg_color_hover = bg_color_hover
|
||||
self._bg_color_pressed = bg_color_pressed
|
||||
self._icon_color = icon_color
|
||||
self._icon_color_hover = icon_color_hover
|
||||
self._icon_color_pressed = icon_color_pressed
|
||||
self._icon_color_active = icon_color_active
|
||||
self._context_color = context_color
|
||||
self._top_margin = self.height() + 6
|
||||
self._is_active = is_active
|
||||
# Set Parameters
|
||||
self._set_bg_color = bg_color
|
||||
self._set_icon_path = icon_path
|
||||
self._set_icon_color = icon_color
|
||||
self._set_border_radius = radius
|
||||
# Parent
|
||||
self._parent = parent
|
||||
self._app_parent = app_parent
|
||||
|
||||
# TOOLTIP
|
||||
self._tooltip_text = tooltip_text
|
||||
self._tooltip = _ToolTip(
|
||||
app_parent,
|
||||
tooltip_text,
|
||||
dark_one,
|
||||
context_color,
|
||||
text_foreground
|
||||
)
|
||||
self._tooltip.hide()
|
||||
|
||||
# SET ACTIVE MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def set_active(self, is_active):
|
||||
self._is_active = is_active
|
||||
self.repaint()
|
||||
|
||||
# RETURN IF IS ACTIVE MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def is_active(self):
|
||||
return self._is_active
|
||||
|
||||
# PAINT EVENT
|
||||
# painting the button and the icon
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def paintEvent(self, event):
|
||||
# PAINTER
|
||||
paint = QPainter()
|
||||
paint.begin(self)
|
||||
paint.setRenderHint(QPainter.RenderHint.Antialiasing)
|
||||
|
||||
if self._is_active:
|
||||
# BRUSH
|
||||
brush = QBrush(QColor(self._context_color))
|
||||
else:
|
||||
# BRUSH
|
||||
brush = QBrush(QColor(self._set_bg_color))
|
||||
|
||||
# CREATE RECTANGLE
|
||||
rect = QRect(0, 0, self.width(), self.height())
|
||||
paint.setPen(Qt.NoPen)
|
||||
paint.setBrush(brush)
|
||||
paint.drawRoundedRect(
|
||||
rect,
|
||||
self._set_border_radius,
|
||||
self._set_border_radius
|
||||
)
|
||||
|
||||
# DRAW ICONS
|
||||
self.icon_paint(paint, self._set_icon_path, rect)
|
||||
|
||||
# END PAINTER
|
||||
paint.end()
|
||||
|
||||
# CHANGE STYLES
|
||||
# Functions with custom styles
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def change_style(self, event):
|
||||
if event == QEvent.Enter:
|
||||
self._set_bg_color = self._bg_color_hover
|
||||
self._set_icon_color = self._icon_color_hover
|
||||
self.repaint()
|
||||
elif event == QEvent.Leave:
|
||||
self._set_bg_color = self._bg_color
|
||||
self._set_icon_color = self._icon_color
|
||||
self.repaint()
|
||||
elif event == QEvent.MouseButtonPress:
|
||||
self._set_bg_color = self._bg_color_pressed
|
||||
self._set_icon_color = self._icon_color_pressed
|
||||
self.repaint()
|
||||
elif event == QEvent.MouseButtonRelease:
|
||||
self._set_bg_color = self._bg_color_hover
|
||||
self._set_icon_color = self._icon_color_hover
|
||||
self.repaint()
|
||||
|
||||
# MOUSE OVER
|
||||
# Event triggered when the mouse is over the BTN
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def enterEvent(self, event):
|
||||
self.change_style(QEvent.Enter)
|
||||
self.move_tooltip()
|
||||
self._tooltip.show()
|
||||
|
||||
# MOUSE LEAVE
|
||||
# Event fired when the mouse leaves the BTN
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def leaveEvent(self, event):
|
||||
self.change_style(QEvent.Leave)
|
||||
self.move_tooltip()
|
||||
self._tooltip.hide()
|
||||
|
||||
# MOUSE PRESS
|
||||
# Event triggered when the left button is pressed
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def mousePressEvent(self, event):
|
||||
if event.button() == Qt.LeftButton:
|
||||
self.change_style(QEvent.MouseButtonPress)
|
||||
# SET FOCUS
|
||||
self.setFocus()
|
||||
# EMIT SIGNAL
|
||||
return self.clicked.emit()
|
||||
|
||||
# MOUSE RELEASED
|
||||
# Event triggered after the mouse button is released
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def mouseReleaseEvent(self, event):
|
||||
if event.button() == Qt.LeftButton:
|
||||
self.change_style(QEvent.MouseButtonRelease)
|
||||
# EMIT SIGNAL
|
||||
return self.released.emit()
|
||||
|
||||
# DRAW ICON WITH COLORS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def icon_paint(self, qp, image, rect):
|
||||
icon = QPixmap(image)
|
||||
painter = QPainter(icon)
|
||||
painter.setCompositionMode(QPainter.CompositionMode_SourceIn)
|
||||
if self._is_active:
|
||||
painter.fillRect(icon.rect(), self._icon_color_active)
|
||||
else:
|
||||
painter.fillRect(icon.rect(), self._set_icon_color)
|
||||
qp.drawPixmap(
|
||||
(rect.width() - icon.width()) / 2,
|
||||
(rect.height() - icon.height()) / 2,
|
||||
icon
|
||||
)
|
||||
painter.end()
|
||||
|
||||
# SET ICON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def set_icon(self, icon_path):
|
||||
self._set_icon_path = icon_path
|
||||
self.repaint()
|
||||
|
||||
# MOVE TOOLTIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def move_tooltip(self):
|
||||
# GET MAIN WINDOW PARENT
|
||||
gp = self.mapToGlobal(QPoint(0, 0))
|
||||
|
||||
# SET WIDGET TO GET POSTION
|
||||
# Return absolute position of widget inside app
|
||||
pos = self._parent.mapFromGlobal(gp)
|
||||
|
||||
# FORMAT POSITION
|
||||
# Adjust tooltip position with offset
|
||||
pos_x = (pos.x() - self._tooltip.width()) + self.width() + 5
|
||||
pos_y = pos.y() + self._top_margin
|
||||
|
||||
# SET POSITION TO WIDGET
|
||||
# Move tooltip position
|
||||
self._tooltip.move(pos_x, pos_y)
|
||||
|
||||
# TOOLTIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class _ToolTip(QLabel):
|
||||
# TOOLTIP / LABEL StyleSheet
|
||||
style_tooltip = """
|
||||
QLabel {{
|
||||
background-color: {_dark_one};
|
||||
color: {_text_foreground};
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
border-radius: 17px;
|
||||
border: 0px solid transparent;
|
||||
border-right: 3px solid {_context_color};
|
||||
font: 800 9pt "Segoe UI";
|
||||
}}
|
||||
"""
|
||||
def __init__(
|
||||
self,
|
||||
parent,
|
||||
tooltip,
|
||||
dark_one,
|
||||
context_color,
|
||||
text_foreground
|
||||
):
|
||||
QLabel.__init__(self)
|
||||
|
||||
# LABEL SETUP
|
||||
style = self.style_tooltip.format(
|
||||
_dark_one = dark_one,
|
||||
_context_color = context_color,
|
||||
_text_foreground = text_foreground
|
||||
)
|
||||
self.setObjectName(u"label_tooltip")
|
||||
self.setStyleSheet(style)
|
||||
self.setMinimumHeight(34)
|
||||
self.setParent(parent)
|
||||
self.setText(tooltip)
|
||||
self.adjustSize()
|
||||
|
||||
# SET DROP SHADOW
|
||||
self.shadow = QGraphicsDropShadowEffect(self)
|
||||
self.shadow.setBlurRadius(30)
|
||||
self.shadow.setXOffset(0)
|
||||
self.shadow.setYOffset(0)
|
||||
self.shadow.setColor(QColor(0, 0, 0, 80))
|
||||
self.setGraphicsEffect(self.shadow)
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# PY PUSH BUTTON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# PY PUSH BUTTON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_toggle import PyToggle
|
||||
@@ -1,88 +1,88 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
class PyToggle(QCheckBox):
|
||||
def __init__(
|
||||
self,
|
||||
width = 50,
|
||||
bg_color = "#777",
|
||||
circle_color = "#DDD",
|
||||
active_color = "#00BCFF",
|
||||
animation_curve = QEasingCurve.OutBounce
|
||||
):
|
||||
QCheckBox.__init__(self)
|
||||
self.setFixedSize(width, 28)
|
||||
self.setCursor(Qt.PointingHandCursor)
|
||||
|
||||
# COLORS
|
||||
self._bg_color = bg_color
|
||||
self._circle_color = circle_color
|
||||
self._active_color = active_color
|
||||
|
||||
self._position = 3
|
||||
self.animation = QPropertyAnimation(self, b"position")
|
||||
self.animation.setEasingCurve(animation_curve)
|
||||
self.animation.setDuration(500)
|
||||
self.stateChanged.connect(self.setup_animation)
|
||||
|
||||
@Property(float)
|
||||
def position(self):
|
||||
return self._position
|
||||
|
||||
@position.setter
|
||||
def position(self, pos):
|
||||
self._position = pos
|
||||
self.update()
|
||||
|
||||
# START STOP ANIMATION
|
||||
def setup_animation(self, value):
|
||||
self.animation.stop()
|
||||
if value:
|
||||
self.animation.setEndValue(self.width() - 26)
|
||||
else:
|
||||
self.animation.setEndValue(4)
|
||||
self.animation.start()
|
||||
|
||||
def hitButton(self, pos: QPoint):
|
||||
return self.contentsRect().contains(pos)
|
||||
|
||||
def paintEvent(self, e):
|
||||
p = QPainter(self)
|
||||
p.setRenderHint(QPainter.Antialiasing)
|
||||
p.setFont(QFont("Segoe UI", 9))
|
||||
|
||||
# SET PEN
|
||||
p.setPen(Qt.NoPen)
|
||||
|
||||
# DRAW RECT
|
||||
rect = QRect(0, 0, self.width(), self.height())
|
||||
|
||||
if not self.isChecked():
|
||||
p.setBrush(QColor(self._bg_color))
|
||||
p.drawRoundedRect(0,0,rect.width(), 28, 14, 14)
|
||||
p.setBrush(QColor(self._circle_color))
|
||||
p.drawEllipse(self._position, 3, 22, 22)
|
||||
else:
|
||||
p.setBrush(QColor(self._active_color))
|
||||
p.drawRoundedRect(0,0,rect.width(), 28, 14, 14)
|
||||
p.setBrush(QColor(self._circle_color))
|
||||
p.drawEllipse(self._position, 3, 22, 22)
|
||||
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
class PyToggle(QCheckBox):
|
||||
def __init__(
|
||||
self,
|
||||
width = 50,
|
||||
bg_color = "#777",
|
||||
circle_color = "#DDD",
|
||||
active_color = "#00BCFF",
|
||||
animation_curve = QEasingCurve.OutBounce
|
||||
):
|
||||
QCheckBox.__init__(self)
|
||||
self.setFixedSize(width, 28)
|
||||
self.setCursor(Qt.PointingHandCursor)
|
||||
|
||||
# COLORS
|
||||
self._bg_color = bg_color
|
||||
self._circle_color = circle_color
|
||||
self._active_color = active_color
|
||||
|
||||
self._position = 3
|
||||
self.animation = QPropertyAnimation(self, b"position")
|
||||
self.animation.setEasingCurve(animation_curve)
|
||||
self.animation.setDuration(500)
|
||||
self.stateChanged.connect(self.setup_animation)
|
||||
|
||||
@Property(float)
|
||||
def position(self):
|
||||
return self._position
|
||||
|
||||
@position.setter
|
||||
def position(self, pos):
|
||||
self._position = pos
|
||||
self.update()
|
||||
|
||||
# START STOP ANIMATION
|
||||
def setup_animation(self, value):
|
||||
self.animation.stop()
|
||||
if value:
|
||||
self.animation.setEndValue(self.width() - 26)
|
||||
else:
|
||||
self.animation.setEndValue(4)
|
||||
self.animation.start()
|
||||
|
||||
def hitButton(self, pos: QPoint):
|
||||
return self.contentsRect().contains(pos)
|
||||
|
||||
def paintEvent(self, e):
|
||||
p = QPainter(self)
|
||||
p.setRenderHint(QPainter.Antialiasing)
|
||||
p.setFont(QFont("Segoe UI", 9))
|
||||
|
||||
# SET PEN
|
||||
p.setPen(Qt.NoPen)
|
||||
|
||||
# DRAW RECT
|
||||
rect = QRect(0, 0, self.width(), self.height())
|
||||
|
||||
if not self.isChecked():
|
||||
p.setBrush(QColor(self._bg_color))
|
||||
p.drawRoundedRect(0,0,rect.width(), 28, 14, 14)
|
||||
p.setBrush(QColor(self._circle_color))
|
||||
p.drawEllipse(self._position, 3, 22, 22)
|
||||
else:
|
||||
p.setBrush(QColor(self._active_color))
|
||||
p.drawRoundedRect(0,0,rect.width(), 28, 14, 14)
|
||||
p.setBrush(QColor(self._circle_color))
|
||||
p.drawEllipse(self._position, 3, 22, 22)
|
||||
|
||||
p.end()
|
||||
@@ -1,19 +1,19 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT WIDGETS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT WIDGETS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_window import PyWindow
|
||||
+141
-141
@@ -1,142 +1,142 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT PACKAGES AND MODULES
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# IMPORT SETTINGS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from gui.core.json_settings import Settings
|
||||
|
||||
# IMPORT STYLES
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . styles import Styles
|
||||
|
||||
# PY WINDOW
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyWindow(QFrame):
|
||||
def __init__(
|
||||
self,
|
||||
parent,
|
||||
layout = Qt.Vertical,
|
||||
margin = 0,
|
||||
spacing = 2,
|
||||
bg_color = "#2c313c",
|
||||
text_color = "#fff",
|
||||
text_font = "9pt 'Segoe UI'",
|
||||
border_radius = 10,
|
||||
border_size = 2,
|
||||
border_color = "#343b48",
|
||||
enable_shadow = True
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
# LOAD SETTINGS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
settings = Settings()
|
||||
self.settings = settings.items
|
||||
|
||||
# PROPERTIES
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self.parent = parent
|
||||
self.layout = layout
|
||||
self.margin = margin
|
||||
self.bg_color = bg_color
|
||||
self.text_color = text_color
|
||||
self.text_font = text_font
|
||||
self.border_radius = border_radius
|
||||
self.border_size = border_size
|
||||
self.border_color = border_color
|
||||
self.enable_shadow = enable_shadow
|
||||
|
||||
# OBJECT NAME
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self.setObjectName("pod_bg_app")
|
||||
|
||||
# APPLY STYLESHEET
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self.set_stylesheet()
|
||||
|
||||
# ADD LAYOUT
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
if layout == Qt.Vertical:
|
||||
# VERTICAL LAYOUT
|
||||
self.layout = QHBoxLayout(self)
|
||||
else:
|
||||
# HORIZONTAL LAYOUT
|
||||
self.layout = QHBoxLayout(self)
|
||||
self.layout.setContentsMargins(margin, margin, margin, margin)
|
||||
self.layout.setSpacing(spacing)
|
||||
|
||||
# ADD DROP SHADOW
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
if self.settings["custom_title_bar"]:
|
||||
if enable_shadow:
|
||||
self.shadow = QGraphicsDropShadowEffect()
|
||||
self.shadow.setBlurRadius(20)
|
||||
self.shadow.setXOffset(0)
|
||||
self.shadow.setYOffset(0)
|
||||
self.shadow.setColor(QColor(0, 0, 0, 160))
|
||||
self.setGraphicsEffect(self.shadow)
|
||||
|
||||
# APPLY AND UPDATE STYLESHEET
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def set_stylesheet(
|
||||
self,
|
||||
bg_color = None,
|
||||
border_radius = None,
|
||||
border_size = None,
|
||||
border_color = None,
|
||||
text_color = None,
|
||||
text_font = None
|
||||
):
|
||||
# CHECK BG COLOR
|
||||
if bg_color != None: internal_bg_color = bg_color
|
||||
else: internal_bg_color = self.bg_color
|
||||
|
||||
# CHECK BORDER RADIUS
|
||||
if border_radius != None: internal_border_radius = border_radius
|
||||
else: internal_border_radius = self.border_radius
|
||||
|
||||
# CHECK BORDER SIZE
|
||||
if border_size != None: internal_border_size = border_size
|
||||
else: internal_border_size = self.border_size
|
||||
|
||||
# CHECK BORDER COLOR
|
||||
if text_color != None: internal_text_color = text_color
|
||||
else: internal_text_color = self.text_color
|
||||
|
||||
# CHECK TEXT COLOR
|
||||
if border_color != None: internal_border_color = border_color
|
||||
else: internal_border_color = self.border_color
|
||||
|
||||
# CHECK TEXT COLOR
|
||||
if text_font != None: internal_text_font = text_font
|
||||
else: internal_text_font = self.text_font
|
||||
|
||||
self.setStyleSheet(Styles.bg_style.format(
|
||||
_bg_color = internal_bg_color,
|
||||
_border_radius = internal_border_radius,
|
||||
_border_size = internal_border_size,
|
||||
_border_color = internal_border_color,
|
||||
_text_color = internal_text_color,
|
||||
_text_font = internal_text_font
|
||||
))
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT PACKAGES AND MODULES
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
|
||||
# IMPORT SETTINGS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from gui.core.json_settings import Settings
|
||||
|
||||
# IMPORT STYLES
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . styles import Styles
|
||||
|
||||
# PY WINDOW
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyWindow(QFrame):
|
||||
def __init__(
|
||||
self,
|
||||
parent,
|
||||
layout = Qt.Vertical,
|
||||
margin = 0,
|
||||
spacing = 2,
|
||||
bg_color = "#2c313c",
|
||||
text_color = "#fff",
|
||||
text_font = "9pt 'Segoe UI'",
|
||||
border_radius = 10,
|
||||
border_size = 2,
|
||||
border_color = "#343b48",
|
||||
enable_shadow = True
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
# LOAD SETTINGS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
settings = Settings()
|
||||
self.settings = settings.items
|
||||
|
||||
# PROPERTIES
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self.parent = parent
|
||||
self.layout = layout
|
||||
self.margin = margin
|
||||
self.bg_color = bg_color
|
||||
self.text_color = text_color
|
||||
self.text_font = text_font
|
||||
self.border_radius = border_radius
|
||||
self.border_size = border_size
|
||||
self.border_color = border_color
|
||||
self.enable_shadow = enable_shadow
|
||||
|
||||
# OBJECT NAME
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self.setObjectName("pod_bg_app")
|
||||
|
||||
# APPLY STYLESHEET
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self.set_stylesheet()
|
||||
|
||||
# ADD LAYOUT
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
if layout == Qt.Vertical:
|
||||
# VERTICAL LAYOUT
|
||||
self.layout = QHBoxLayout(self)
|
||||
else:
|
||||
# HORIZONTAL LAYOUT
|
||||
self.layout = QHBoxLayout(self)
|
||||
self.layout.setContentsMargins(margin, margin, margin, margin)
|
||||
self.layout.setSpacing(spacing)
|
||||
|
||||
# ADD DROP SHADOW
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
if self.settings["custom_title_bar"]:
|
||||
if enable_shadow:
|
||||
self.shadow = QGraphicsDropShadowEffect()
|
||||
self.shadow.setBlurRadius(20)
|
||||
self.shadow.setXOffset(0)
|
||||
self.shadow.setYOffset(0)
|
||||
self.shadow.setColor(QColor(0, 0, 0, 160))
|
||||
self.setGraphicsEffect(self.shadow)
|
||||
|
||||
# APPLY AND UPDATE STYLESHEET
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def set_stylesheet(
|
||||
self,
|
||||
bg_color = None,
|
||||
border_radius = None,
|
||||
border_size = None,
|
||||
border_color = None,
|
||||
text_color = None,
|
||||
text_font = None
|
||||
):
|
||||
# CHECK BG COLOR
|
||||
if bg_color != None: internal_bg_color = bg_color
|
||||
else: internal_bg_color = self.bg_color
|
||||
|
||||
# CHECK BORDER RADIUS
|
||||
if border_radius != None: internal_border_radius = border_radius
|
||||
else: internal_border_radius = self.border_radius
|
||||
|
||||
# CHECK BORDER SIZE
|
||||
if border_size != None: internal_border_size = border_size
|
||||
else: internal_border_size = self.border_size
|
||||
|
||||
# CHECK BORDER COLOR
|
||||
if text_color != None: internal_text_color = text_color
|
||||
else: internal_text_color = self.text_color
|
||||
|
||||
# CHECK TEXT COLOR
|
||||
if border_color != None: internal_border_color = border_color
|
||||
else: internal_border_color = self.border_color
|
||||
|
||||
# CHECK TEXT COLOR
|
||||
if text_font != None: internal_text_font = text_font
|
||||
else: internal_text_font = self.text_font
|
||||
|
||||
self.setStyleSheet(Styles.bg_style.format(
|
||||
_bg_color = internal_bg_color,
|
||||
_border_radius = internal_border_radius,
|
||||
_border_size = internal_border_size,
|
||||
_border_color = internal_border_color,
|
||||
_text_color = internal_text_color,
|
||||
_text_font = internal_text_font
|
||||
))
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
class Styles(object):
|
||||
bg_style = """
|
||||
#pod_bg_app {{
|
||||
background-color: {_bg_color};
|
||||
border-radius: {_border_radius};
|
||||
border: {_border_size}px solid {_border_color};
|
||||
}}
|
||||
QFrame {{
|
||||
color: {_text_color};
|
||||
font: {_text_font};
|
||||
}}
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# BY: WANDERSON M.PIMENTA
|
||||
# PROJECT MADE WITH: Qt Designer and PySide6
|
||||
# V: 1.0.0
|
||||
#
|
||||
# This project can be used freely for all uses, as long as they maintain the
|
||||
# respective credits only in the Python scripts, any information in the visual
|
||||
# interface (GUI) can be modified without any implication.
|
||||
#
|
||||
# There are limitations on Qt licenses if you want to use your products
|
||||
# commercially, I recommend reading them on the official website:
|
||||
# https://doc.qt.io/qtforpython/licenses.html
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
class Styles(object):
|
||||
bg_style = """
|
||||
#pod_bg_app {{
|
||||
background-color: {_bg_color};
|
||||
border-radius: {_border_radius};
|
||||
border: {_border_size}px solid {_border_color};
|
||||
}}
|
||||
QFrame {{
|
||||
color: {_text_color};
|
||||
font: {_text_font};
|
||||
}}
|
||||
"""
|
||||
Reference in New Issue
Block a user