mirror of
https://github.com/Wanderson-Magalhaes/Modern_GUI_PyDracula_PySide6_or_PyQt6.git
synced 2026-04-04 12:58:50 +00:00
v1.0.0
This commit is contained in:
30
modules/__init__.py
Normal file
30
modules/__init__.py
Normal file
@@ -0,0 +1,30 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# 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 PySide6.QtCore import *
|
||||
from PySide6.QtGui import *
|
||||
from PySide6.QtWidgets import *
|
||||
|
||||
# GUI FILE
|
||||
from . ui_main import Ui_MainWindow
|
||||
|
||||
# APP SETTINGS
|
||||
from . app_settings import Settings
|
||||
|
||||
# IMPORT FUNCTIONS
|
||||
from . ui_functions import *
|
||||
|
||||
# APP FUNCTIONS
|
||||
from . app_functions import *
|
||||
42
modules/app_functions.py
Normal file
42
modules/app_functions.py
Normal file
@@ -0,0 +1,42 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# MAIN FILE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from main import *
|
||||
|
||||
# WITH ACCESS TO MAIN WINDOW WIDGETS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class AppFunctions(MainWindow):
|
||||
def setThemeHack(self):
|
||||
Settings.BTN_LEFT_BOX_COLOR = "background-color: #495474;"
|
||||
Settings.BTN_RIGHT_BOX_COLOR = "background-color: #495474;"
|
||||
Settings.MENU_SELECTED_STYLESHEET = MENU_SELECTED_STYLESHEET = """
|
||||
border-left: 22px solid qlineargradient(spread:pad, x1:0.034, y1:0, x2:0.216, y2:0, stop:0.499 rgba(255, 121, 198, 255), stop:0.5 rgba(85, 170, 255, 0));
|
||||
background-color: #566388;
|
||||
"""
|
||||
|
||||
# SET MANUAL STYLES
|
||||
self.ui.lineEdit.setStyleSheet("background-color: #6272a4;")
|
||||
self.ui.pushButton.setStyleSheet("background-color: #6272a4;")
|
||||
self.ui.plainTextEdit.setStyleSheet("background-color: #6272a4;")
|
||||
self.ui.tableWidget.setStyleSheet("QScrollBar:vertical { background: #6272a4; } QScrollBar:horizontal { background: #6272a4; }")
|
||||
self.ui.scrollArea.setStyleSheet("QScrollBar:vertical { background: #6272a4; } QScrollBar:horizontal { background: #6272a4; }")
|
||||
self.ui.comboBox.setStyleSheet("background-color: #6272a4;")
|
||||
self.ui.horizontalScrollBar.setStyleSheet("background-color: #6272a4;")
|
||||
self.ui.verticalScrollBar.setStyleSheet("background-color: #6272a4;")
|
||||
self.ui.commandLinkButton.setStyleSheet("color: #ff79c6;")
|
||||
|
||||
18
modules/app_settings.py
Normal file
18
modules/app_settings.py
Normal file
@@ -0,0 +1,18 @@
|
||||
class Settings():
|
||||
# APP SETTINGS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
ENABLE_CUSTOM_TITLE_BAR = True
|
||||
MENU_WIDTH = 240
|
||||
LEFT_BOX_WIDTH = 240
|
||||
RIGHT_BOX_WIDTH = 240
|
||||
TIME_ANIMATION = 500
|
||||
|
||||
# BTNS LEFT AND RIGHT BOX COLORS
|
||||
BTN_LEFT_BOX_COLOR = "background-color: rgb(44, 49, 58);"
|
||||
BTN_RIGHT_BOX_COLOR = "background-color: #ff79c6;"
|
||||
|
||||
# MENU SELECTED STYLESHEET
|
||||
MENU_SELECTED_STYLESHEET = """
|
||||
border-left: 22px solid qlineargradient(spread:pad, x1:0.034, y1:0, x2:0.216, y2:0, stop:0.499 rgba(255, 121, 198, 255), stop:0.5 rgba(85, 170, 255, 0));
|
||||
background-color: rgb(40, 44, 52);
|
||||
"""
|
||||
34150
modules/resources_rc.py
Normal file
34150
modules/resources_rc.py
Normal file
File diff suppressed because it is too large
Load Diff
241
modules/ui_functions.py
Normal file
241
modules/ui_functions.py
Normal file
@@ -0,0 +1,241 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# MAIN FILE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from main import *
|
||||
|
||||
# GLOBALS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
GLOBAL_STATE = False
|
||||
GLOBAL_TITLE_BAR = True
|
||||
|
||||
class UIFunctions(MainWindow):
|
||||
# MAXIMIZE/RESTORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def maximize_restore(self):
|
||||
global GLOBAL_STATE
|
||||
status = GLOBAL_STATE
|
||||
if status == False:
|
||||
self.showMaximized()
|
||||
GLOBAL_STATE = True
|
||||
self.ui.appMargins.setContentsMargins(0, 0, 0, 0)
|
||||
self.ui.maximizeRestoreAppBtn.setToolTip("Restore")
|
||||
self.ui.maximizeRestoreAppBtn.setIcon(QIcon(u":/icons/images/icons/icon_restore.png"))
|
||||
self.ui.frame_size_grip.hide()
|
||||
else:
|
||||
GLOBAL_STATE = False
|
||||
self.showNormal()
|
||||
self.resize(self.width()+1, self.height()+1)
|
||||
self.ui.appMargins.setContentsMargins(10, 10, 10, 10)
|
||||
self.ui.maximizeRestoreAppBtn.setToolTip("Maximize")
|
||||
self.ui.maximizeRestoreAppBtn.setIcon(QIcon(u":/icons/images/icons/icon_maximize.png"))
|
||||
self.ui.frame_size_grip.show()
|
||||
|
||||
# RETURN STATUS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def returStatus(self):
|
||||
return GLOBAL_STATE
|
||||
|
||||
# SET STATUS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def setStatus(self, status):
|
||||
global GLOBAL_STATE
|
||||
GLOBAL_STATE = status
|
||||
|
||||
# TOGGLE MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def toggleMenu(self, enable):
|
||||
if enable:
|
||||
# GET WIDTH
|
||||
width = self.ui.leftMenuBg.width()
|
||||
maxExtend = Settings.MENU_WIDTH
|
||||
standard = 60
|
||||
|
||||
# SET MAX WIDTH
|
||||
if width == 60:
|
||||
widthExtended = maxExtend
|
||||
else:
|
||||
widthExtended = standard
|
||||
|
||||
# ANIMATION
|
||||
self.animation = QPropertyAnimation(self.ui.leftMenuBg, b"minimumWidth")
|
||||
self.animation.setDuration(Settings.TIME_ANIMATION)
|
||||
self.animation.setStartValue(width)
|
||||
self.animation.setEndValue(widthExtended)
|
||||
self.animation.setEasingCurve(QEasingCurve.InOutQuart)
|
||||
self.animation.start()
|
||||
|
||||
# TOGGLE LEFT BOX
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def toggleLeftBox(self, enable):
|
||||
if enable:
|
||||
# GET WIDTH
|
||||
width = self.ui.extraLeftBox.width()
|
||||
widthRightBox = self.ui.extraRightBox.width()
|
||||
maxExtend = Settings.LEFT_BOX_WIDTH
|
||||
color = Settings.BTN_LEFT_BOX_COLOR
|
||||
standard = 0
|
||||
|
||||
# GET BTN STYLE
|
||||
style = self.ui.toggleLeftBox.styleSheet()
|
||||
|
||||
# SET MAX WIDTH
|
||||
if width == 0:
|
||||
widthExtended = maxExtend
|
||||
# SELECT BTN
|
||||
self.ui.toggleLeftBox.setStyleSheet(style + color)
|
||||
if widthRightBox != 0:
|
||||
style = self.ui.settingsTopBtn.styleSheet()
|
||||
self.ui.settingsTopBtn.setStyleSheet(style.replace(Settings.BTN_RIGHT_BOX_COLOR, ''))
|
||||
self.ui.extraRightBox.setMinimumWidth(0)
|
||||
else:
|
||||
widthExtended = standard
|
||||
# RESET BTN
|
||||
self.ui.toggleLeftBox.setStyleSheet(style.replace(color, ''))
|
||||
|
||||
# ANIMATION
|
||||
self.animation = QPropertyAnimation(self.ui.extraLeftBox, b"minimumWidth")
|
||||
self.animation.setDuration(Settings.TIME_ANIMATION)
|
||||
self.animation.setStartValue(width)
|
||||
self.animation.setEndValue(widthExtended)
|
||||
self.animation.setEasingCurve(QEasingCurve.InOutQuart)
|
||||
self.animation.start()
|
||||
|
||||
# TOGGLE RIGHT BOX
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def toggleRightBox(self, enable):
|
||||
if enable:
|
||||
# GET WIDTH
|
||||
width = self.ui.extraRightBox.width()
|
||||
widthLeftBox = self.ui.extraLeftBox.width()
|
||||
maxExtend = Settings.RIGHT_BOX_WIDTH
|
||||
color = Settings.BTN_RIGHT_BOX_COLOR
|
||||
standard = 0
|
||||
|
||||
# GET BTN STYLE
|
||||
style = self.ui.settingsTopBtn.styleSheet()
|
||||
|
||||
# SET MAX WIDTH
|
||||
if width == 0:
|
||||
widthExtended = maxExtend
|
||||
# SELECT BTN
|
||||
self.ui.settingsTopBtn.setStyleSheet(style + color)
|
||||
if widthLeftBox != 0:
|
||||
style = self.ui.toggleLeftBox.styleSheet()
|
||||
self.ui.toggleLeftBox.setStyleSheet(style.replace(Settings.BTN_LEFT_BOX_COLOR, ''))
|
||||
self.ui.extraLeftBox.setMinimumWidth(0)
|
||||
else:
|
||||
widthExtended = standard
|
||||
# RESET BTN
|
||||
self.ui.settingsTopBtn.setStyleSheet(style.replace(color, ''))
|
||||
|
||||
# ANIMATION
|
||||
self.animation = QPropertyAnimation(self.ui.extraRightBox, b"minimumWidth")
|
||||
self.animation.setDuration(Settings.TIME_ANIMATION)
|
||||
self.animation.setStartValue(width)
|
||||
self.animation.setEndValue(widthExtended)
|
||||
self.animation.setEasingCurve(QEasingCurve.InOutQuart)
|
||||
self.animation.start()
|
||||
|
||||
# SELECT/DESELECT MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
# SELECT
|
||||
def selectMenu(getStyle):
|
||||
select = getStyle + Settings.MENU_SELECTED_STYLESHEET
|
||||
return select
|
||||
|
||||
# DESELECT
|
||||
def deselectMenu(getStyle):
|
||||
deselect = getStyle.replace(Settings.MENU_SELECTED_STYLESHEET, "")
|
||||
return deselect
|
||||
|
||||
# START SELECTION
|
||||
def selectStandardMenu(self, widget):
|
||||
for w in self.ui.topMenu.findChildren(QPushButton):
|
||||
if w.objectName() == widget:
|
||||
w.setStyleSheet(UIFunctions.selectMenu(w.styleSheet()))
|
||||
|
||||
# RESET SELECTION
|
||||
def resetStyle(self, widget):
|
||||
for w in self.ui.topMenu.findChildren(QPushButton):
|
||||
if w.objectName() != widget:
|
||||
w.setStyleSheet(UIFunctions.deselectMenu(w.styleSheet()))
|
||||
|
||||
# IMPORT THEMES FILES QSS/CSS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def theme(self, file, useCustomTheme):
|
||||
if useCustomTheme:
|
||||
str = open(file, 'r').read()
|
||||
self.ui.styleSheet.setStyleSheet(str)
|
||||
|
||||
# START - GUI DEFINITIONS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def uiDefinitions(self):
|
||||
def dobleClickMaximizeRestore(event):
|
||||
# IF DOUBLE CLICK CHANGE STATUS
|
||||
if event.type() == QEvent.MouseButtonDblClick:
|
||||
QTimer.singleShot(250, lambda: UIFunctions.maximize_restore(self))
|
||||
self.ui.titleRightInfo.mouseDoubleClickEvent = dobleClickMaximizeRestore
|
||||
|
||||
if Settings.ENABLE_CUSTOM_TITLE_BAR:
|
||||
#STANDARD TITLE BAR
|
||||
self.setWindowFlags(Qt.FramelessWindowHint)
|
||||
self.setAttribute(Qt.WA_TranslucentBackground)
|
||||
|
||||
# MOVE WINDOW / MAXIMIZE / RESTORE
|
||||
def moveWindow(event):
|
||||
# IF MAXIMIZED CHANGE TO NORMAL
|
||||
if UIFunctions.returStatus(self):
|
||||
UIFunctions.maximize_restore(self)
|
||||
# MOVE WINDOW
|
||||
if event.buttons() == Qt.LeftButton:
|
||||
self.move(self.pos() + event.globalPos() - self.dragPos)
|
||||
self.dragPos = event.globalPos()
|
||||
event.accept()
|
||||
|
||||
self.ui.titleRightInfo.mouseMoveEvent = moveWindow
|
||||
|
||||
else:
|
||||
self.ui.appMargins.setContentsMargins(0, 0, 0, 0)
|
||||
self.ui.minimizeAppBtn.hide()
|
||||
self.ui.maximizeRestoreAppBtn.hide()
|
||||
self.ui.closeAppBtn.hide()
|
||||
self.ui.frame_size_grip.hide()
|
||||
|
||||
# DROP SHADOW
|
||||
self.shadow = QGraphicsDropShadowEffect(self)
|
||||
self.shadow.setBlurRadius(17)
|
||||
self.shadow.setXOffset(0)
|
||||
self.shadow.setYOffset(0)
|
||||
self.shadow.setColor(QColor(0, 0, 0, 150))
|
||||
self.ui.bgApp.setGraphicsEffect(self.shadow)
|
||||
|
||||
# RESIZE WINDOW
|
||||
self.sizegrip = QSizeGrip(self.ui.frame_size_grip)
|
||||
self.sizegrip.setStyleSheet("width: 20px; height: 20px; margin 0px; padding: 0px;")
|
||||
|
||||
# MINIMIZE
|
||||
self.ui.minimizeAppBtn.clicked.connect(lambda: self.showMinimized())
|
||||
|
||||
# MAXIMIZE/RESTORE
|
||||
self.ui.maximizeRestoreAppBtn.clicked.connect(lambda: UIFunctions.maximize_restore(self))
|
||||
|
||||
# CLOSE APPLICATION
|
||||
self.ui.closeAppBtn.clicked.connect(lambda: self.close())
|
||||
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
# END - GUI DEFINITIONS
|
||||
1660
modules/ui_main.py
Normal file
1660
modules/ui_main.py
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user