mirror of
https://github.com/Wanderson-Magalhaes/Modern_GUI_PyDracula_PySide6_or_PyQt6.git
synced 2026-02-17 07:53:56 +00:00
v1.0.0
This commit is contained in:
155
main.py
Normal file
155
main.py
Normal file
@@ -0,0 +1,155 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# 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 sys
|
||||
import platform
|
||||
|
||||
# IMPORT / GUI AND MODULES
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from modules import *
|
||||
|
||||
# SET AS GLOBAL WIDGETS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
widgets = None
|
||||
|
||||
class MainWindow(QMainWindow):
|
||||
def __init__(self):
|
||||
QMainWindow.__init__(self)
|
||||
|
||||
# SET AS GLOBAL WIDGETS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self.ui = Ui_MainWindow()
|
||||
self.ui.setupUi(self)
|
||||
global widgets
|
||||
widgets = self.ui
|
||||
|
||||
# USE CUSTOM TITLE BAR | USE AS "False" FOR MAC OR LINUX
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
Settings.ENABLE_CUSTOM_TITLE_BAR = True
|
||||
|
||||
# APP NAME
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
title = "PyDracula - Modern GUI"
|
||||
description = "PyDracula APP - Theme with colors based on Dracula for Python."
|
||||
# APPLY TEXTS
|
||||
self.setWindowTitle(title)
|
||||
widgets.titleRightInfo.setText(description)
|
||||
|
||||
# TOGGLE MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
widgets.toggleButton.clicked.connect(lambda: UIFunctions.toggleMenu(self, True))
|
||||
|
||||
# SET UI DEFINITIONS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
UIFunctions.uiDefinitions(self)
|
||||
|
||||
# QTableWidget PARAMETERS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
widgets.tableWidget.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
|
||||
|
||||
# BUTTONS CLICK
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# LEFT MENUS
|
||||
widgets.btn_home.clicked.connect(self.buttonClick)
|
||||
widgets.btn_widgets.clicked.connect(self.buttonClick)
|
||||
widgets.btn_new.clicked.connect(self.buttonClick)
|
||||
widgets.btn_save.clicked.connect(self.buttonClick)
|
||||
|
||||
# EXTRA LEFT BOX
|
||||
def openCloseLeftBox():
|
||||
UIFunctions.toggleLeftBox(self, True)
|
||||
widgets.toggleLeftBox.clicked.connect(openCloseLeftBox)
|
||||
widgets.extraCloseColumnBtn.clicked.connect(openCloseLeftBox)
|
||||
|
||||
# EXTRA RIGHT BOX
|
||||
def openCloseRightBox():
|
||||
UIFunctions.toggleRightBox(self, True)
|
||||
widgets.settingsTopBtn.clicked.connect(openCloseRightBox)
|
||||
|
||||
# SHOW APP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self.show()
|
||||
|
||||
# SET CUSTOM THEME
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
useCustomTheme = False
|
||||
themeFile = "themes\py_dracula_light.qss"
|
||||
|
||||
# SET THEME AND HACKS
|
||||
if useCustomTheme:
|
||||
# LOAD AND APPLY STYLE
|
||||
UIFunctions.theme(self, themeFile, True)
|
||||
|
||||
# SET HACKS
|
||||
AppFunctions.setThemeHack(self)
|
||||
|
||||
# SET HOME PAGE AND SELECT MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
widgets.stackedWidget.setCurrentWidget(widgets.home)
|
||||
widgets.btn_home.setStyleSheet(UIFunctions.selectMenu(widgets.btn_home.styleSheet()))
|
||||
|
||||
|
||||
# BUTTONS CLICK
|
||||
# Post here your functions for clicked buttons
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def buttonClick(self):
|
||||
# GET BUTTON CLICKED
|
||||
btn = self.sender()
|
||||
btnName = btn.objectName()
|
||||
|
||||
# SHOW HOME PAGE
|
||||
if btnName == "btn_home":
|
||||
widgets.stackedWidget.setCurrentWidget(widgets.home)
|
||||
UIFunctions.resetStyle(self, btnName)
|
||||
btn.setStyleSheet(UIFunctions.selectMenu(btn.styleSheet()))
|
||||
|
||||
# SHOW WIDGETS PAGE
|
||||
if btnName == "btn_widgets":
|
||||
widgets.stackedWidget.setCurrentWidget(widgets.widgets)
|
||||
UIFunctions.resetStyle(self, btnName)
|
||||
btn.setStyleSheet(UIFunctions.selectMenu(btn.styleSheet()))
|
||||
|
||||
# SHOW NEW PAGE
|
||||
if btnName == "btn_new":
|
||||
widgets.stackedWidget.setCurrentWidget(widgets.new_page) # SET PAGE
|
||||
UIFunctions.resetStyle(self, btnName) # RESET ANOTHERS BUTTONS SELECTED
|
||||
btn.setStyleSheet(UIFunctions.selectMenu(btn.styleSheet())) # SELECT MENU
|
||||
|
||||
if btnName == "btn_save":
|
||||
print("Save BTN clicked!")
|
||||
|
||||
# PRINT BTN NAME
|
||||
print(f'Button "{btnName}" pressed!')
|
||||
|
||||
|
||||
# MOUSE CLICK EVENTS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def mousePressEvent(self, event):
|
||||
# SET DRAG POS WINDOW
|
||||
self.dragPos = event.globalPos()
|
||||
|
||||
# PRINT MOUSE EVENTS
|
||||
if event.buttons() == Qt.LeftButton:
|
||||
print('Mouse click: LEFT CLICK')
|
||||
if event.buttons() == Qt.RightButton:
|
||||
print('Mouse click: RIGHT CLICK')
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QApplication(sys.argv)
|
||||
app.setWindowIcon(QIcon("icon.ico"))
|
||||
window = MainWindow()
|
||||
sys.exit(app.exec_())
|
||||
Reference in New Issue
Block a user