mirror of
https://github.com/Wanderson-Magalhaes/PyOneDark_Qt_Widgets_Modern_GUI.git
synced 2026-02-17 07:53:57 +00:00
144 lines
4.8 KiB
Python
144 lines
4.8 KiB
Python
# ///////////////////////////////////////////////////////////////
|
|
#
|
|
# 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 os
|
|
|
|
# IMPORT QT CORE
|
|
# ///////////////////////////////////////////////////////////////
|
|
from qt_core import *
|
|
|
|
# IMPORT SETTINGS
|
|
# ///////////////////////////////////////////////////////////////
|
|
from gui.core.json_settings import Settings
|
|
|
|
# IMPORT PY ONE DARK WINDOWS
|
|
# ///////////////////////////////////////////////////////////////
|
|
# MAIN WINDOW
|
|
from gui.uis.windows.main_window import *
|
|
|
|
# IMPORT PY ONE DARK WIDGETS
|
|
# ///////////////////////////////////////////////////////////////
|
|
from gui.widgets import *
|
|
|
|
# ADJUST QT FONT DPI FOR HIGHT SCALE
|
|
# ///////////////////////////////////////////////////////////////
|
|
os.environ["QT_FONT_DPI"] = "96"
|
|
|
|
# MAIN WINDOW
|
|
# ///////////////////////////////////////////////////////////////
|
|
class MainWindow(QMainWindow):
|
|
def __init__(self):
|
|
QMainWindow.__init__(self)
|
|
|
|
# SETUP MAIN WINDOw
|
|
# Load widgets from "gui\uis\main_window\ui_main.py"
|
|
# ///////////////////////////////////////////////////////////////
|
|
self.ui = UI_MainWindow()
|
|
self.ui.setup_ui(self)
|
|
|
|
# LOAD SETTINGS
|
|
# ///////////////////////////////////////////////////////////////
|
|
settings = Settings()
|
|
self.settings = settings.items
|
|
|
|
# SETUP MAIN WINDOW
|
|
# ///////////////////////////////////////////////////////////////
|
|
self.hide_grips = True # Show/Hide resize grips
|
|
SetupMainWindow.setup(self)
|
|
|
|
# LEFT MENUS / GET SIGNALS WHEN LEFT MENU BTN IS CLICKED / RELEASED
|
|
# ///////////////////////////////////////////////////////////////
|
|
# ADD MENUS
|
|
self.ui.left_menu.add_menus(SetupMainWindow.add_left_menus)
|
|
|
|
# SET SIGNALS
|
|
self.ui.left_menu.clicked.connect(self.left_menu_btn_clicked)
|
|
self.ui.left_menu.released.connect(self.left_menu_btn_released)
|
|
|
|
# TITLE BAR / ADD EXTRA BUTTONS
|
|
# ///////////////////////////////////////////////////////////////
|
|
# ADD MENUS
|
|
self.ui.title_bar.add_menus(SetupMainWindow.add_title_bar_menus)
|
|
|
|
# SET SIGNALS
|
|
self.ui.title_bar.clicked.connect(self.left_menu_btn_clicked)
|
|
self.ui.title_bar.released.connect(self.left_menu_btn_released)
|
|
|
|
# ADD Title
|
|
if self.settings["custom_title_bar"]:
|
|
self.ui.title_bar.set_title(self.settings["app_name"])
|
|
else:
|
|
self.ui.title_bar.set_title("Welcome to PyOneDark")
|
|
|
|
|
|
|
|
# SHOW MAIN WINDOW
|
|
# ///////////////////////////////////////////////////////////////
|
|
self.show()
|
|
|
|
# LEFT MENU BTN IS CLICKED
|
|
# Run function when btn is clicked
|
|
# Check funtion by object name / btn_id
|
|
# ///////////////////////////////////////////////////////////////
|
|
def left_menu_btn_clicked(self):
|
|
# GET BT CLICKED
|
|
btn = SetupMainWindow.setup_btns(self)
|
|
|
|
# SELECT / DESELECT BTN HOME
|
|
if btn.objectName() == "btn_home":
|
|
if btn.is_active():
|
|
btn.set_active(False)
|
|
else:
|
|
btn.set_active(True)
|
|
|
|
# DEBUG
|
|
print(f"Button {btn.objectName()}, clicked!")
|
|
|
|
# LEFT MENU BTN IS RELEASED
|
|
# Run function when btn is released
|
|
# Check funtion by object name / btn_id
|
|
# ///////////////////////////////////////////////////////////////
|
|
def left_menu_btn_released(self):
|
|
# GET BT CLICKED
|
|
btn = SetupMainWindow.setup_btns(self)
|
|
|
|
# DEBUG
|
|
print(f"Button {btn.objectName()}, released!")
|
|
|
|
# RESIZE EVENT
|
|
# ///////////////////////////////////////////////////////////////
|
|
def resizeEvent(self, event):
|
|
SetupMainWindow.resize_grips(self)
|
|
|
|
# MOUSE CLICK EVENTS
|
|
# ///////////////////////////////////////////////////////////////
|
|
def mousePressEvent(self, event):
|
|
# SET DRAG POS WINDOW
|
|
self.dragPos = event.globalPos()
|
|
|
|
|
|
# SETTINGS WHEN TO START
|
|
# Set the initial class and also additional parameters of the "QApplication" class
|
|
# ///////////////////////////////////////////////////////////////
|
|
if __name__ == "__main__":
|
|
# APPLICATION
|
|
app = QApplication(sys.argv)
|
|
# app.setWindowIcon(QIcon("icon.ico"))
|
|
window = MainWindow()
|
|
sys.exit(app.exec_()) |