hydraveil-gui/gui/v2/ui/pages/currency_selection_page.py
2026-06-13 16:19:11 -04:00

65 lines
2.5 KiB
Python
Executable file

import os
from PyQt6.QtWidgets import QButtonGroup, QLabel, QPushButton
from PyQt6.QtGui import QIcon
from PyQt6.QtCore import QSize
from PyQt6 import QtCore
from gui.v2.ui.pages.Page import Page
class CurrencySelectionPage(Page):
def __init__(self, page_stack, main_window=None, parent=None):
super().__init__("Select Currency", page_stack, main_window, parent)
self.update_status = main_window
self.selected_duration = None
self.create_interface_elements()
self.button_reverse.setVisible(True)
self.button_next.setVisible(False)
def create_interface_elements(self):
self.title = QLabel("Payment Method", self)
self.title.setGeometry(QtCore.QRect(510, 30, 250, 40))
self.title.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
self.button_reverse.clicked.connect(self.reverse)
button_info = [
("monero", (545, 75)),
("bitcoin", (545, 290)),
("lightnering", (545, 180)),
("litecoin", (545, 395))
]
self.buttonGroup = QButtonGroup(self)
self.buttons = []
for j, (icon_name, position) in enumerate(button_info):
button = QPushButton(self)
button.setGeometry(position[0], position[1], 185, 75)
button.setIconSize(QSize(190, 120))
button.setCheckable(True)
self.buttons.append(button)
self.buttonGroup.addButton(button, j)
button.setIcon(
QIcon(os.path.join(self.btn_path, f"{icon_name}.png")))
button.clicked.connect(self.on_currency_selected)
def on_currency_selected(self):
self.custom_window.navigator.navigate("payment_details")
payment_details_page = self.custom_window.navigator.get_cached("payment_details")
if payment_details_page is not None:
payment_details_page.selected_duration = self.selected_duration
payment_details_page.selected_currency = self.get_selected_currency()
payment_details_page.check_invoice()
self.update_status.update_status('Loading payment details...')
def get_selected_currency(self):
selected_button = self.buttonGroup.checkedButton()
if selected_button:
index = self.buttonGroup.id(selected_button)
currencies = ["monero", "bitcoin", "lightning", "litecoin"]
return currencies[index]
return None
def reverse(self):
self.custom_window.navigator.navigate("duration_selection")