86 lines
3.1 KiB
Python
Executable file
86 lines
3.1 KiB
Python
Executable file
import os
|
|
|
|
from PyQt6.QtWidgets import QWidget, QLabel, QPushButton
|
|
from PyQt6.QtGui import QIcon
|
|
from PyQt6 import QtCore
|
|
|
|
|
|
class Page(QWidget):
|
|
|
|
def __init__(self, name, page_stack, custom_window, parent=None):
|
|
super().__init__(parent)
|
|
self.custom_window = custom_window
|
|
self.btn_path = custom_window.btn_path
|
|
self.name = name
|
|
self.page_stack = page_stack
|
|
self.init_ui()
|
|
self.selected_profiles = []
|
|
self.selected_wireguard = []
|
|
self.selected_residential = []
|
|
self.buttons = []
|
|
|
|
def add_selected_profile(self, profile):
|
|
self.selected_profiles.clear()
|
|
self.selected_wireguard.clear()
|
|
self.selected_residential.clear()
|
|
self.selected_profiles.append(profile)
|
|
|
|
def init_ui(self):
|
|
self.title = QLabel(self)
|
|
self.title.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
|
|
self.title.setObjectName("titles")
|
|
|
|
self.display = QLabel(self)
|
|
self.display.setObjectName("display")
|
|
self.display.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
|
|
buttons_info = [
|
|
(QPushButton, "button_back", "back", (660, 534, 48, 35)),
|
|
(QPushButton, "button_next", "next", (720, 534, 48, 35)),
|
|
(QPushButton, "button_reverse", "back", (660, 534, 48, 35)),
|
|
(QPushButton, "button_go", "next", (720, 534, 48, 35)),
|
|
(QPushButton, "button_apply", "apply", (720, 534, 48, 35)),
|
|
]
|
|
for button_type, object_name, icon_name, geometry in buttons_info:
|
|
button = button_type(self)
|
|
button.setObjectName(object_name)
|
|
button.setGeometry(*geometry)
|
|
button.setIcon(
|
|
QIcon(os.path.join(self.btn_path, f"{icon_name}.png")))
|
|
button.setIconSize(QtCore.QSize(48, 35))
|
|
button.setVisible(False)
|
|
if object_name == "button_back":
|
|
self.button_back = button
|
|
self.button_back.clicked.connect(self.gestionar_back)
|
|
if object_name == "button_next":
|
|
self.button_next = button
|
|
self.button_next.clicked.connect(self.gestionar_next)
|
|
if object_name == "button_reverse":
|
|
self.button_reverse = button
|
|
self.button_reverse.clicked.connect(self.limpiar)
|
|
|
|
if object_name == "button_go":
|
|
self.button_go = button
|
|
self.button_go.clicked.connect(self.limpiar)
|
|
|
|
if object_name == "button_apply":
|
|
self.button_apply = button
|
|
|
|
def gestionar_back(self):
|
|
current_index = self.page_stack.currentIndex()
|
|
if current_index == 18:
|
|
return
|
|
if current_index > 0:
|
|
self.page_stack.setCurrentIndex(current_index - 1)
|
|
|
|
def gestionar_next(self):
|
|
current_index = self.page_stack.currentIndex()
|
|
next_index = (current_index + 1) % self.page_stack.count()
|
|
self.page_stack.setCurrentIndex(next_index)
|
|
self.limpiar()
|
|
|
|
def limpiar(self):
|
|
self.display.clear()
|
|
for boton in self.buttons:
|
|
boton.setChecked(False)
|
|
|
|
self.button_next.setVisible(False)
|