mirror of
https://github.com/Wanderson-Magalhaes/PyOneDark_Qt_Widgets_Modern_GUI.git
synced 2026-02-17 07:53:57 +00:00
02/06/2021
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
<item>
|
||||
<widget class="QStackedWidget" name="pages">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="menu_1">
|
||||
<property name="styleSheet">
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<item>
|
||||
<widget class="QStackedWidget" name="pages">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="menu_1">
|
||||
<property name="styleSheet">
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<item>
|
||||
<widget class="QStackedWidget" name="pages">
|
||||
<property name="currentIndex">
|
||||
<number>2</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page_1">
|
||||
<property name="styleSheet">
|
||||
|
||||
@@ -51,7 +51,7 @@ class MainFunctions():
|
||||
):
|
||||
self.ui.left_column.menus.pages.setCurrentWidget(menu)
|
||||
self.ui.left_column.title_label.setText(title)
|
||||
self.ui.left_column.icon.load(icon_path)
|
||||
self.ui.left_column.icon.set_icon(icon_path)
|
||||
|
||||
# RETURN IF LEFT COLUMN IS VISIBLE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -100,6 +100,14 @@ class SetupMainWindow:
|
||||
"show_top" : True,
|
||||
"is_active" : False
|
||||
},
|
||||
{
|
||||
"btn_icon" : "icon_widgets.svg",
|
||||
"btn_id" : "btn_info",
|
||||
"btn_text" : "Information",
|
||||
"btn_tooltip" : "Open informations",
|
||||
"show_top" : False,
|
||||
"is_active" : False
|
||||
},
|
||||
{
|
||||
"btn_icon" : "icon_settings.svg",
|
||||
"btn_id" : "btn_settings",
|
||||
|
||||
70
gui/widgets/py_left_column/py_icon.py
Normal file
70
gui/widgets/py_left_column/py_icon.py
Normal file
@@ -0,0 +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)
|
||||
|
||||
@@ -22,6 +22,10 @@ from qt_core import *
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_left_button import *
|
||||
|
||||
# IMPORT ICON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_icon import *
|
||||
|
||||
# IMPORT LEFT COLUMN
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from gui.uis.columns.ui_left_column import Ui_LeftColumn
|
||||
@@ -120,6 +124,7 @@ class PyLeftColumn(QWidget):
|
||||
# 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()
|
||||
@@ -128,7 +133,7 @@ class PyLeftColumn(QWidget):
|
||||
self.icon_layout = QVBoxLayout(self.icon_frame)
|
||||
self.icon_layout.setContentsMargins(0,0,0,0)
|
||||
self.icon_layout.setSpacing(5)
|
||||
self.icon = QSvgWidget(self._icon_path)
|
||||
self.icon = PyIcon(self._icon_path, self._icon_color)
|
||||
self.icon_layout.addWidget(self.icon, Qt.AlignCenter, Qt.AlignCenter)
|
||||
|
||||
# LABEL
|
||||
|
||||
@@ -202,12 +202,27 @@ class PyLeftMenu(QWidget):
|
||||
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):
|
||||
|
||||
@@ -50,6 +50,7 @@ class PyLeftMenuButton(QPushButton):
|
||||
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__()
|
||||
@@ -80,6 +81,7 @@ class PyLeftMenuButton(QPushButton):
|
||||
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
|
||||
@@ -134,6 +136,29 @@ class PyLeftMenuButton(QPushButton):
|
||||
# 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:
|
||||
@@ -170,14 +195,29 @@ class PyLeftMenuButton(QPushButton):
|
||||
self._is_active = is_active
|
||||
if not is_active:
|
||||
self._set_icon_color = self._icon_color
|
||||
if not is_active:
|
||||
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
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user