mirror of
https://github.com/Wanderson-Magalhaes/PyOneDark_Qt_Widgets_Modern_GUI.git
synced 2026-08-20 06:13:17 +00:00
01/06/2021
This commit is contained in:
@@ -27,14 +27,119 @@ from qt_core import *
|
||||
from . ui_main import *
|
||||
|
||||
# FUNCTIONS
|
||||
class FunctionsMain():
|
||||
class MainFunctions():
|
||||
def __init__(self):
|
||||
super(FunctionsMain, self).__init__()
|
||||
super().__init__()
|
||||
# SETUP MAIN WINDOw
|
||||
# Load widgets from "gui\uis\main_window\ui_main.py"
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self.ui = UI_MainWindow()
|
||||
self.ui.setup_ui(self)
|
||||
|
||||
# SET MAIN WINDOW PAGES
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def set_page(self, page):
|
||||
self.ui.load_pages.pages.setCurrentWidget(page)
|
||||
self.ui.load_pages.pages.setCurrentWidget(page)
|
||||
|
||||
# SET LEFT COLUMN PAGES
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def set_left_column_menu(
|
||||
self,
|
||||
menu,
|
||||
title,
|
||||
icon_path
|
||||
):
|
||||
self.ui.left_column.menus.pages.setCurrentWidget(menu)
|
||||
self.ui.left_column.title_label.setText(title)
|
||||
self.ui.left_column.icon.load(icon_path)
|
||||
|
||||
# RETURN IF LEFT COLUMN IS VISIBLE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def left_column_is_visible(self):
|
||||
width = self.ui.left_column_frame.width()
|
||||
if width == 0:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
# RETURN IF RIGHT COLUMN IS VISIBLE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def right_column_is_visible(self):
|
||||
width = self.ui.right_column_frame.width()
|
||||
if width == 0:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
# SET RIGHT COLUMN PAGES
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def set_right_column_menu(self, menu):
|
||||
self.ui.right_column.pages.setCurrentWidget(menu)
|
||||
|
||||
# GET TITLE BUTTON BY OBJECT NAME
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def get_title_bar_btn(self, object_name):
|
||||
return self.ui.title_bar_frame.findChild(QPushButton, object_name)
|
||||
|
||||
# GET TITLE BUTTON BY OBJECT NAME
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def get_left_menu_btn(self, object_name):
|
||||
return self.ui.left_menu.findChild(QPushButton, object_name)
|
||||
|
||||
# LEDT AND RIGHT COLUMNS / SHOW / HIDE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def toggle_left_column(self):
|
||||
# GET ACTUAL CLUMNS SIZE
|
||||
width = self.ui.left_column_frame.width()
|
||||
right_column_width = self.ui.right_column_frame.width()
|
||||
|
||||
MainFunctions.start_box_animation(self, width, right_column_width, "left")
|
||||
|
||||
def toggle_right_column(self):
|
||||
# GET ACTUAL CLUMNS SIZE
|
||||
left_column_width = self.ui.left_column_frame.width()
|
||||
width = self.ui.right_column_frame.width()
|
||||
|
||||
MainFunctions.start_box_animation(self, left_column_width, width, "right")
|
||||
|
||||
def start_box_animation(self, left_box_width, right_box_width, direction):
|
||||
right_width = 0
|
||||
left_width = 0
|
||||
time_animation = self.ui.settings["time_animation"]
|
||||
minimum_left = self.ui.settings["left_column_size"]["minimum"]
|
||||
maximum_left = self.ui.settings["left_column_size"]["maximum"]
|
||||
minimum_right = self.ui.settings["right_column_size"]["minimum"]
|
||||
maximum_right = self.ui.settings["right_column_size"]["maximum"]
|
||||
|
||||
# Check Left Values
|
||||
if left_box_width == minimum_left and direction == "left":
|
||||
left_width = maximum_left
|
||||
else:
|
||||
left_width = minimum_left
|
||||
|
||||
# Check Right values
|
||||
if right_box_width == minimum_right and direction == "right":
|
||||
right_width = maximum_right
|
||||
else:
|
||||
right_width = minimum_right
|
||||
|
||||
# ANIMATION LEFT BOX
|
||||
self.left_box = QPropertyAnimation(self.ui.left_column_frame, b"minimumWidth")
|
||||
self.left_box.setDuration(time_animation)
|
||||
self.left_box.setStartValue(left_box_width)
|
||||
self.left_box.setEndValue(left_width)
|
||||
self.left_box.setEasingCurve(QEasingCurve.InOutQuart)
|
||||
|
||||
# ANIMATION RIGHT BOX
|
||||
self.right_box = QPropertyAnimation(self.ui.right_column_frame, b"minimumWidth")
|
||||
self.right_box.setDuration(time_animation)
|
||||
self.right_box.setStartValue(right_box_width)
|
||||
self.right_box.setEndValue(right_width)
|
||||
self.right_box.setEasingCurve(QEasingCurve.InOutQuart)
|
||||
|
||||
# GROUP ANIMATION
|
||||
self.group = QParallelAnimationGroup()
|
||||
self.group.stop()
|
||||
self.group.addAnimation(self.left_box)
|
||||
self.group.addAnimation(self.right_box)
|
||||
self.group.start()
|
||||
@@ -34,9 +34,20 @@ from gui.core.json_themes import Themes
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from gui.widgets import *
|
||||
|
||||
# LOAD UI MAIN
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . ui_main import *
|
||||
|
||||
# PY WINDOW
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class SetupMainWindow:
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
# SETUP MAIN WINDOw
|
||||
# Load widgets from "gui\uis\main_window\ui_main.py"
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self.ui = UI_MainWindow()
|
||||
self.ui.setup_ui(self)
|
||||
|
||||
# ADD LEFT MENUS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
@@ -112,7 +123,7 @@ class SetupMainWindow:
|
||||
"btn_icon" : "icon_settings.svg",
|
||||
"btn_id" : "btn_top_settings",
|
||||
"btn_tooltip" : "Top settings",
|
||||
"is_active" : True
|
||||
"is_active" : False
|
||||
}
|
||||
]
|
||||
|
||||
@@ -124,10 +135,12 @@ class SetupMainWindow:
|
||||
return self.ui.title_bar.sender()
|
||||
elif self.ui.left_menu.sender() != None:
|
||||
return self.ui.left_menu.sender()
|
||||
elif self.ui.left_column.sender() != None:
|
||||
return self.ui.left_column.sender()
|
||||
|
||||
# SETUP MAIN WINDOW WITH CUSTOM PARAMETERS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def setup(self):
|
||||
def setup_gui(self):
|
||||
# APP TITLE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self.setWindowTitle(self.settings["app_name"])
|
||||
|
||||
@@ -140,10 +140,9 @@ class UI_MainWindow(object):
|
||||
# ADD LEFT COLUMN
|
||||
# Add here the left column with Stacked Widgets
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
left_column_minimum = self.settings["left_column_size"]["minimum"]
|
||||
self.left_column_frame = QFrame()
|
||||
self.left_column_frame.setMaximumSize(left_column_minimum, 17280)
|
||||
self.left_column_frame.setMinimumSize(left_column_minimum, 0)
|
||||
self.left_column_frame.setMaximumWidth(self.settings["left_column_size"]["minimum"])
|
||||
self.left_column_frame.setMinimumWidth(self.settings["left_column_size"]["minimum"])
|
||||
self.left_column_frame.setStyleSheet(f"background: {self.themes['app_color']['bg_two']}")
|
||||
|
||||
# ADD LAYOUT TO LEFT COLUMN
|
||||
@@ -230,13 +229,13 @@ class UI_MainWindow(object):
|
||||
self.load_pages.setupUi(self.content_area_left_frame)
|
||||
|
||||
# RIGHT BAR
|
||||
self.content_area_right_frame = QFrame()
|
||||
self.content_area_right_frame.setMinimumWidth(self.settings["right_column_size"]["minimum"])
|
||||
self.content_area_right_frame.setMaximumWidth(self.settings["right_column_size"]["maximum"])
|
||||
self.right_column_frame = QFrame()
|
||||
self.right_column_frame.setMinimumWidth(self.settings["right_column_size"]["minimum"])
|
||||
self.right_column_frame.setMaximumWidth(self.settings["right_column_size"]["minimum"])
|
||||
|
||||
# IMPORT RIGHT COLUMN
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self.content_area_right_layout = QVBoxLayout(self.content_area_right_frame)
|
||||
self.content_area_right_layout = QVBoxLayout(self.right_column_frame)
|
||||
self.content_area_right_layout.setContentsMargins(5,5,5,5)
|
||||
self.content_area_right_layout.setSpacing(0)
|
||||
|
||||
@@ -259,7 +258,7 @@ class UI_MainWindow(object):
|
||||
|
||||
# ADD TO LAYOUTS
|
||||
self.content_area_layout.addWidget(self.content_area_left_frame)
|
||||
self.content_area_layout.addWidget(self.content_area_right_frame)
|
||||
self.content_area_layout.addWidget(self.right_column_frame)
|
||||
|
||||
# CREDITS / BOTTOM APP FRAME
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -27,6 +27,10 @@ from . py_left_button import *
|
||||
from gui.uis.columns.ui_left_column import Ui_LeftColumn
|
||||
|
||||
class PyLeftColumn(QWidget):
|
||||
# SIGNALS
|
||||
clicked = Signal(object)
|
||||
released = Signal(object)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
parent,
|
||||
@@ -70,9 +74,23 @@ class PyLeftColumn(QWidget):
|
||||
self.setup_ui()
|
||||
|
||||
# ADD LEFT COLUMN TO BG FRAME
|
||||
self.left_column = Ui_LeftColumn()
|
||||
self.left_column.setupUi(self.content_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)
|
||||
@@ -148,7 +166,7 @@ class PyLeftColumn(QWidget):
|
||||
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)
|
||||
|
||||
@@ -235,7 +235,7 @@ class PyLeftMenu(QWidget):
|
||||
|
||||
# BOTTOM LAYOUT
|
||||
self.bottom_layout = QVBoxLayout(self.bottom_frame)
|
||||
self.bottom_layout.setContentsMargins(0,0,0,0)
|
||||
self.bottom_layout.setContentsMargins(0,0,0,8)
|
||||
self.bottom_layout.setSpacing(1)
|
||||
|
||||
# ADD TOP AND BOTTOM FRAME
|
||||
|
||||
Reference in New Issue
Block a user