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>
|
<item>
|
||||||
<widget class="QStackedWidget" name="pages">
|
<widget class="QStackedWidget" name="pages">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>1</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="menu_1">
|
<widget class="QWidget" name="menu_1">
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QStackedWidget" name="pages">
|
<widget class="QStackedWidget" name="pages">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>1</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="menu_1">
|
<widget class="QWidget" name="menu_1">
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QStackedWidget" name="pages">
|
<widget class="QStackedWidget" name="pages">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>2</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="page_1">
|
<widget class="QWidget" name="page_1">
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class MainFunctions():
|
|||||||
):
|
):
|
||||||
self.ui.left_column.menus.pages.setCurrentWidget(menu)
|
self.ui.left_column.menus.pages.setCurrentWidget(menu)
|
||||||
self.ui.left_column.title_label.setText(title)
|
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
|
# RETURN IF LEFT COLUMN IS VISIBLE
|
||||||
# ///////////////////////////////////////////////////////////////
|
# ///////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -100,6 +100,14 @@ class SetupMainWindow:
|
|||||||
"show_top" : True,
|
"show_top" : True,
|
||||||
"is_active" : False
|
"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_icon" : "icon_settings.svg",
|
||||||
"btn_id" : "btn_settings",
|
"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 *
|
from . py_left_button import *
|
||||||
|
|
||||||
|
# IMPORT ICON
|
||||||
|
# ///////////////////////////////////////////////////////////////
|
||||||
|
from . py_icon import *
|
||||||
|
|
||||||
# IMPORT LEFT COLUMN
|
# IMPORT LEFT COLUMN
|
||||||
# ///////////////////////////////////////////////////////////////
|
# ///////////////////////////////////////////////////////////////
|
||||||
from gui.uis.columns.ui_left_column import Ui_LeftColumn
|
from gui.uis.columns.ui_left_column import Ui_LeftColumn
|
||||||
@@ -120,6 +124,7 @@ class PyLeftColumn(QWidget):
|
|||||||
# LAYOUT TITLE BG
|
# LAYOUT TITLE BG
|
||||||
self.title_bg_layout = QHBoxLayout(self.title_bg_frame)
|
self.title_bg_layout = QHBoxLayout(self.title_bg_frame)
|
||||||
self.title_bg_layout.setContentsMargins(5,5,5,5)
|
self.title_bg_layout.setContentsMargins(5,5,5,5)
|
||||||
|
self.title_bg_layout.setSpacing(3)
|
||||||
|
|
||||||
# ICON
|
# ICON
|
||||||
self.icon_frame = QFrame()
|
self.icon_frame = QFrame()
|
||||||
@@ -128,7 +133,7 @@ class PyLeftColumn(QWidget):
|
|||||||
self.icon_layout = QVBoxLayout(self.icon_frame)
|
self.icon_layout = QVBoxLayout(self.icon_frame)
|
||||||
self.icon_layout.setContentsMargins(0,0,0,0)
|
self.icon_layout.setContentsMargins(0,0,0,0)
|
||||||
self.icon_layout.setSpacing(5)
|
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)
|
self.icon_layout.addWidget(self.icon, Qt.AlignCenter, Qt.AlignCenter)
|
||||||
|
|
||||||
# LABEL
|
# LABEL
|
||||||
|
|||||||
@@ -202,12 +202,27 @@ class PyLeftMenu(QWidget):
|
|||||||
else:
|
else:
|
||||||
btn.set_active(False)
|
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
|
# DESELECT ALL BTNs
|
||||||
# ///////////////////////////////////////////////////////////////
|
# ///////////////////////////////////////////////////////////////
|
||||||
def deselect_all(self):
|
def deselect_all(self):
|
||||||
for btn in self.findChildren(QPushButton):
|
for btn in self.findChildren(QPushButton):
|
||||||
btn.set_active(False)
|
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
|
# SETUP APP
|
||||||
# ///////////////////////////////////////////////////////////////
|
# ///////////////////////////////////////////////////////////////
|
||||||
def setup_ui(self):
|
def setup_ui(self):
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ class PyLeftMenuButton(QPushButton):
|
|||||||
icon_path = "icon_add_user.svg",
|
icon_path = "icon_add_user.svg",
|
||||||
icon_active_menu = "active_menu.svg",
|
icon_active_menu = "active_menu.svg",
|
||||||
is_active = False,
|
is_active = False,
|
||||||
|
is_active_tab = False,
|
||||||
is_toggle_active = False
|
is_toggle_active = False
|
||||||
):
|
):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@@ -80,6 +81,7 @@ class PyLeftMenuButton(QPushButton):
|
|||||||
self._set_text_active = text_active
|
self._set_text_active = text_active
|
||||||
self._parent = app_parent
|
self._parent = app_parent
|
||||||
self._is_active = is_active
|
self._is_active = is_active
|
||||||
|
self._is_active_tab = is_active_tab
|
||||||
self._is_toggle_active = is_toggle_active
|
self._is_toggle_active = is_toggle_active
|
||||||
|
|
||||||
# TOOLTIP
|
# TOOLTIP
|
||||||
@@ -134,6 +136,29 @@ class PyLeftMenuButton(QPushButton):
|
|||||||
# DRAW ICONS
|
# DRAW ICONS
|
||||||
self.icon_paint(p, self._icon_path, rect_icon, self._set_icon_color)
|
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
|
# NORMAL BG
|
||||||
else:
|
else:
|
||||||
if self._is_toggle_active:
|
if self._is_toggle_active:
|
||||||
@@ -170,14 +195,29 @@ class PyLeftMenuButton(QPushButton):
|
|||||||
self._is_active = is_active
|
self._is_active = is_active
|
||||||
if not is_active:
|
if not is_active:
|
||||||
self._set_icon_color = self._icon_color
|
self._set_icon_color = self._icon_color
|
||||||
if not is_active:
|
|
||||||
self._set_bg_color = self._dark_one
|
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()
|
self.repaint()
|
||||||
|
|
||||||
# RETURN IF IS ACTIVE MENU
|
# RETURN IF IS ACTIVE MENU
|
||||||
# ///////////////////////////////////////////////////////////////
|
# ///////////////////////////////////////////////////////////////
|
||||||
def is_active(self):
|
def is_active(self):
|
||||||
return self._is_active
|
return self._is_active
|
||||||
|
|
||||||
|
# RETURN IF IS ACTIVE TAB MENU
|
||||||
|
# ///////////////////////////////////////////////////////////////
|
||||||
|
def is_active_tab(self):
|
||||||
|
return self._is_active_tab
|
||||||
|
|
||||||
# SET ACTIVE TOGGLE
|
# SET ACTIVE TOGGLE
|
||||||
# ///////////////////////////////////////////////////////////////
|
# ///////////////////////////////////////////////////////////////
|
||||||
|
|||||||
78
main.py
78
main.py
@@ -115,6 +115,14 @@ class MainWindow(QMainWindow):
|
|||||||
# GET BT CLICKED
|
# GET BT CLICKED
|
||||||
btn = SetupMainWindow.setup_btns(self)
|
btn = SetupMainWindow.setup_btns(self)
|
||||||
|
|
||||||
|
# Remove Selection If Clicked By "btn_close_left_column"
|
||||||
|
if btn.objectName() != "btn_settings":
|
||||||
|
self.ui.left_menu.deselect_all_tab()
|
||||||
|
|
||||||
|
# Get Title Bar Btn And Reset Active
|
||||||
|
top_settings = MainFunctions.get_title_bar_btn(self, "btn_top_settings")
|
||||||
|
top_settings.set_active(False)
|
||||||
|
|
||||||
# LEFT MENU
|
# LEFT MENU
|
||||||
# ///////////////////////////////////////////////////////////////
|
# ///////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@@ -143,44 +151,54 @@ class MainWindow(QMainWindow):
|
|||||||
# Load Page 3
|
# Load Page 3
|
||||||
MainFunctions.set_page(self, self.ui.load_pages.page_3)
|
MainFunctions.set_page(self, self.ui.load_pages.page_3)
|
||||||
|
|
||||||
|
# Load Information
|
||||||
|
if btn.objectName() == "btn_info":
|
||||||
|
# CHECK IF LEFT COLUMN IS VISIBLE
|
||||||
|
if not MainFunctions.left_column_is_visible(self):
|
||||||
|
self.ui.left_menu.select_only_one_tab(btn.objectName())
|
||||||
|
|
||||||
|
# Show / Hide
|
||||||
|
MainFunctions.toggle_left_column(self)
|
||||||
|
self.ui.left_menu.select_only_one_tab(btn.objectName())
|
||||||
|
else:
|
||||||
|
if btn.objectName() == "btn_close_left_column":
|
||||||
|
self.ui.left_menu.deselect_all_tab()
|
||||||
|
# Show / Hide
|
||||||
|
MainFunctions.toggle_left_column(self)
|
||||||
|
|
||||||
|
self.ui.left_menu.select_only_one_tab(btn.objectName())
|
||||||
|
|
||||||
# Change Left Column Menu
|
# Change Left Column Menu
|
||||||
MainFunctions.set_left_column_menu(
|
if btn.objectName() != "btn_close_left_column":
|
||||||
self,
|
MainFunctions.set_left_column_menu(
|
||||||
menu = self.ui.left_column.menus.menu_2,
|
self,
|
||||||
title = "Add Users",
|
menu = self.ui.left_column.menus.menu_2,
|
||||||
icon_path = Functions.set_svg_icon("icon_settings.svg")
|
title = "Add Users",
|
||||||
)
|
icon_path = Functions.set_svg_icon("icon_home.svg")
|
||||||
|
)
|
||||||
|
|
||||||
# Settings Left
|
# Settings Left
|
||||||
if btn.objectName() == "btn_settings" or btn.objectName() == "btn_close_left_column":
|
if btn.objectName() == "btn_settings" or btn.objectName() == "btn_close_left_column":
|
||||||
# Toogle Active
|
# CHECK IF LEFT COLUMN IS VISIBLE
|
||||||
if not MainFunctions.left_column_is_visible(self):
|
if not MainFunctions.left_column_is_visible(self):
|
||||||
btn.set_active(True)
|
|
||||||
|
|
||||||
# Show / Hide
|
# Show / Hide
|
||||||
MainFunctions.toggle_left_column(self)
|
MainFunctions.toggle_left_column(self)
|
||||||
|
self.ui.left_menu.select_only_one_tab(btn.objectName())
|
||||||
else:
|
else:
|
||||||
btn.set_active(False)
|
if btn.objectName() == "btn_close_left_column":
|
||||||
|
self.ui.left_menu.deselect_all_tab()
|
||||||
# Show / Hide
|
# Show / Hide
|
||||||
MainFunctions.toggle_left_column(self)
|
MainFunctions.toggle_left_column(self)
|
||||||
|
self.ui.left_menu.select_only_one_tab(btn.objectName())
|
||||||
# Remove Selection If Clicked By "btn_close_left_column"
|
|
||||||
if btn.objectName() != "btn_settings":
|
|
||||||
btn_settings = MainFunctions.get_left_menu_btn(self, "btn_settings")
|
|
||||||
btn_settings.set_active(False)
|
|
||||||
|
|
||||||
# Get Title Bar Btn
|
|
||||||
top_settings = MainFunctions.get_title_bar_btn(self, "btn_top_settings")
|
|
||||||
top_settings.set_active(False)
|
|
||||||
|
|
||||||
# Change Left Column Menu
|
# Change Left Column Menu
|
||||||
MainFunctions.set_left_column_menu(
|
if btn.objectName() != "btn_close_left_column":
|
||||||
self,
|
MainFunctions.set_left_column_menu(
|
||||||
menu = self.ui.left_column.menus.menu_1,
|
self,
|
||||||
title = "Settings Left Column",
|
menu = self.ui.left_column.menus.menu_1,
|
||||||
icon_path = Functions.set_svg_icon("icon_settings.svg")
|
title = "Settings Left Column",
|
||||||
)
|
icon_path = Functions.set_svg_icon("icon_settings.svg")
|
||||||
|
)
|
||||||
|
|
||||||
# TITLE BAR MENU
|
# TITLE BAR MENU
|
||||||
# ///////////////////////////////////////////////////////////////
|
# ///////////////////////////////////////////////////////////////
|
||||||
@@ -199,9 +217,7 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
# Get Left Menu Btn
|
# Get Left Menu Btn
|
||||||
top_settings = MainFunctions.get_left_menu_btn(self, "btn_settings")
|
top_settings = MainFunctions.get_left_menu_btn(self, "btn_settings")
|
||||||
top_settings.set_active(False)
|
top_settings.set_active_tab(False)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# DEBUG
|
# DEBUG
|
||||||
|
|||||||
Reference in New Issue
Block a user