mirror of
https://github.com/RolandWH/SIPPCompare.git
synced 2025-06-07 22:01:32 +01:00
Compare commits
No commits in common. "d8c4b5d64d042974c90a662d06210997a06a5fdf" and "df436fa2b23956b8619c42d078b30f0d9cec831a" have entirely different histories.
d8c4b5d64d
...
df436fa2b2
BIN
SIPPCompare.db
BIN
SIPPCompare.db
Binary file not shown.
@ -1,16 +0,0 @@
|
|||||||
class Platform:
|
|
||||||
def __init__(self, plat_id, fund_plat_fee, plat_name, enabled, fund_deal_fee,
|
|
||||||
share_plat_fee, share_plat_max_fee, share_deal_fee,
|
|
||||||
share_deal_reduce_trades, share_deal_reduce_amount,
|
|
||||||
):
|
|
||||||
|
|
||||||
self.plat_id = plat_id
|
|
||||||
self.fund_plat_fee = fund_plat_fee
|
|
||||||
self.plat_name = plat_name
|
|
||||||
self.enabled = enabled
|
|
||||||
self.fund_deal_fee = fund_deal_fee
|
|
||||||
self.share_plat_fee = share_plat_fee
|
|
||||||
self.share_plat_max_fee = share_plat_max_fee
|
|
||||||
self.share_deal_fee = share_deal_fee
|
|
||||||
self.share_deal_reduce_trades = share_deal_reduce_trades
|
|
||||||
self.share_deal_reduce_amount = share_deal_reduce_amount
|
|
@ -1,7 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import data_struct
|
|
||||||
from data_struct import Platform
|
|
||||||
|
|
||||||
|
|
||||||
class DBHandler:
|
class DBHandler:
|
||||||
@ -10,15 +8,14 @@ class DBHandler:
|
|||||||
self.cur.execute("""
|
self.cur.execute("""
|
||||||
CREATE TABLE "tblPlatforms" (
|
CREATE TABLE "tblPlatforms" (
|
||||||
"PlatformID" INTEGER NOT NULL UNIQUE,
|
"PlatformID" INTEGER NOT NULL UNIQUE,
|
||||||
"PlatformName" TEXT,
|
"PlatformName" TEXT NOT NULL,
|
||||||
"IsEnabled" INTEGER NOT NULL,
|
|
||||||
PRIMARY KEY("PlatformID")
|
PRIMARY KEY("PlatformID")
|
||||||
)
|
)
|
||||||
""")
|
""")
|
||||||
|
|
||||||
self.cur.execute("""
|
self.cur.execute("""
|
||||||
CREATE TABLE "tblFlatPlatFees" (
|
CREATE TABLE "tblFlatPlatFees" (
|
||||||
"PlatformID" INTEGER NOT NULL UNIQUE,
|
"PlatformID" INTEGER NOT NULL,
|
||||||
"SharePlatFee" REAL NOT NULL,
|
"SharePlatFee" REAL NOT NULL,
|
||||||
"SharePlatMaxFee" REAL,
|
"SharePlatMaxFee" REAL,
|
||||||
PRIMARY KEY("PlatformID"),
|
PRIMARY KEY("PlatformID"),
|
||||||
@ -28,7 +25,7 @@ class DBHandler:
|
|||||||
|
|
||||||
self.cur.execute("""
|
self.cur.execute("""
|
||||||
CREATE TABLE "tblFlatDealFees" (
|
CREATE TABLE "tblFlatDealFees" (
|
||||||
"PlatformID" INTEGER NOT NULL UNIQUE,
|
"PlatformID" INTEGER NOT NULL,
|
||||||
"FundDealFee" REAL,
|
"FundDealFee" REAL,
|
||||||
"ShareDealFee" REAL NOT NULL,
|
"ShareDealFee" REAL NOT NULL,
|
||||||
"ShareDealReduceTrades" REAL,
|
"ShareDealReduceTrades" REAL,
|
||||||
@ -50,12 +47,10 @@ class DBHandler:
|
|||||||
|
|
||||||
self.cur.execute("""
|
self.cur.execute("""
|
||||||
CREATE TABLE "tblUserDetails" (
|
CREATE TABLE "tblUserDetails" (
|
||||||
"UserID" INTEGER NOT NULL UNIQUE,
|
"PensionValue" REAL,
|
||||||
"PensionValue" REAL NOT NULL,
|
"SliderValue" INTEGER,
|
||||||
"SliderValue" INTEGER NOT NULL,
|
"ShareTrades" INTEGER,
|
||||||
"ShareTrades" INTEGER NOT NULL,
|
"FundTrades" INTEGER
|
||||||
"FundTrades" INTEGER NOT NULL,
|
|
||||||
PRIMARY KEY("UserID")
|
|
||||||
)
|
)
|
||||||
""")
|
""")
|
||||||
|
|
||||||
@ -70,71 +65,23 @@ class DBHandler:
|
|||||||
create_tables()
|
create_tables()
|
||||||
|
|
||||||
def retrieve_plat_list(self) -> list:
|
def retrieve_plat_list(self) -> list:
|
||||||
res = self.cur.execute("SELECT PlatformName FROM tblPlatforms").fetchall()
|
res = self.cur.execute("SELECT PlatformName FROM tblPlatforms")
|
||||||
|
res_list = res.fetchall()
|
||||||
plat_name_list = []
|
plat_name_list = []
|
||||||
for platform in res:
|
for platform in res_list:
|
||||||
plat_name_list.append(platform[0])
|
plat_name_list.append(platform[0])
|
||||||
|
|
||||||
return plat_name_list
|
return plat_name_list
|
||||||
|
|
||||||
def retrieve_platforms(self) -> list[Platform]:
|
|
||||||
platforms_res = self.cur.execute("""
|
|
||||||
SELECT
|
|
||||||
-- tblPlatforms
|
|
||||||
tblPlatforms.PlatformID, PlatformName, IsEnabled,
|
|
||||||
-- tblFlatPlatFees
|
|
||||||
SharePlatFee, SharePlatMaxFee,
|
|
||||||
-- tblFlatDealFees
|
|
||||||
FundDealFee,
|
|
||||||
ShareDealFee,
|
|
||||||
ShareDealReduceTrades,
|
|
||||||
ShareDealReduceAmount
|
|
||||||
FROM tblPlatforms
|
|
||||||
INNER JOIN tblFlatPlatFees ON
|
|
||||||
tblPlatforms.PlatformID = tblFlatPlatFees.PlatformID
|
|
||||||
INNER JOIN tblFlatDealFees ON
|
|
||||||
tblPlatforms.PlatformID = tblFlatDealFees.PlatformID
|
|
||||||
""").fetchall()
|
|
||||||
|
|
||||||
platforms = []
|
|
||||||
for platform in platforms_res:
|
|
||||||
# plat_id, plat_name, enabled, share_plat_fee, share_plat_max_fee, fund_deal_fee,
|
|
||||||
# share_deal_fee, share_deal_reduce_trades, share_deal_reduce_amount
|
|
||||||
this_platform = [platform[0], platform[1], platform[2], platform[3], platform[4],
|
|
||||||
platform[5], platform[6], platform[7], platform[8]]
|
|
||||||
platforms.append(this_platform)
|
|
||||||
|
|
||||||
for platform in platforms:
|
|
||||||
platform.insert(1, [[], []])
|
|
||||||
|
|
||||||
fund_plat_fee_res = self.cur.execute("SELECT * FROM tblFundPlatFee").fetchall()
|
|
||||||
for i in range(len(fund_plat_fee_res)):
|
|
||||||
plat_id = fund_plat_fee_res[i][0]
|
|
||||||
platforms[plat_id][1][0].append(fund_plat_fee_res[i][1])
|
|
||||||
platforms[plat_id][1][1].append(fund_plat_fee_res[i][2])
|
|
||||||
|
|
||||||
platform_obj_list: list[Platform] = []
|
|
||||||
for platform in platforms:
|
|
||||||
platform_obj_list.append(Platform(
|
|
||||||
platform[0], platform[1], platform[2], platform[3],
|
|
||||||
platform[6], platform[4], platform[5], platform[7],
|
|
||||||
platform[8], platform[9]
|
|
||||||
))
|
|
||||||
|
|
||||||
return platform_obj_list
|
|
||||||
|
|
||||||
|
|
||||||
def write_user_details(self, pension_val: float, slider_val: int, share_trades: int, fund_trades: int):
|
def write_user_details(self, pension_val: float, slider_val: int, share_trades: int, fund_trades: int):
|
||||||
# Hardcode UserID as 0
|
user_details_data = (pension_val, slider_val, share_trades, fund_trades)
|
||||||
user_details_data = (0, pension_val, slider_val, share_trades, fund_trades)
|
|
||||||
|
|
||||||
res = self.cur.execute("SELECT EXISTS(SELECT 1 FROM tblUserDetails)").fetchone()
|
res = self.cur.execute("SELECT EXISTS(SELECT 1 FROM tblUserDetails)").fetchone()
|
||||||
if res[0] == 0:
|
if res[0] == 0:
|
||||||
self.cur.execute("INSERT INTO tblUserDetails VALUES (?, ?, ?, ?, ?)", user_details_data)
|
self.cur.execute("INSERT INTO tblUserDetails VALUES (?, ?, ?, ?)", user_details_data)
|
||||||
else:
|
else:
|
||||||
self.cur.execute("""
|
self.cur.execute("""
|
||||||
UPDATE tblUserDetails SET
|
UPDATE tblUserDetails SET
|
||||||
UserID = ?,
|
|
||||||
PensionValue = ?,
|
PensionValue = ?,
|
||||||
SliderValue = ?,
|
SliderValue = ?,
|
||||||
ShareTrades = ?,
|
ShareTrades = ?,
|
||||||
@ -148,13 +95,12 @@ class DBHandler:
|
|||||||
return {"NO_RECORD": None}
|
return {"NO_RECORD": None}
|
||||||
|
|
||||||
res = self.cur.execute("SELECT * FROM tblUserDetails")
|
res = self.cur.execute("SELECT * FROM tblUserDetails")
|
||||||
res_tuple: tuple = res.fetchone()
|
res_tuple = res.fetchone()
|
||||||
user_details_dict: dict[str, float | int] = {
|
user_details_dict = {
|
||||||
"user_id": res_tuple[0],
|
"pension_val": res_tuple[0],
|
||||||
"pension_val": res_tuple[1],
|
"slider_val": res_tuple[1],
|
||||||
"slider_val": res_tuple[2],
|
"share_trades": res_tuple[2],
|
||||||
"share_trades": res_tuple[3],
|
"fund_trades": res_tuple[3]
|
||||||
"fund_trades": res_tuple[4]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return user_details_dict
|
return user_details_dict
|
||||||
|
@ -3,21 +3,18 @@ from PyQt6.QtWidgets import QApplication
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
import platform_edit
|
import platform_edit
|
||||||
import main_window
|
|
||||||
|
|
||||||
|
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
# Show platform edit window first, before main win
|
# Show platform edit window first, before main win
|
||||||
# When debugging, can be useful to autofill values to save time
|
# When debugging, can be useful to autofill values to save time
|
||||||
"""if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
if sys.argv[1] == "--DEBUG_AUTOFILL":
|
if sys.argv[1] == "--DEBUG_AUTOFILL":
|
||||||
window = platform_edit.PlatformEdit(True)
|
window = platform_edit.PlatformEdit(True)
|
||||||
else:
|
else:
|
||||||
window = platform_edit.PlatformEdit(False)
|
window = platform_edit.PlatformEdit(False)
|
||||||
else:
|
else:
|
||||||
window = platform_edit.PlatformEdit(False)"""
|
window = platform_edit.PlatformEdit(False)
|
||||||
#plat_edit_win = platform_edit.PlatformEdit()
|
|
||||||
window = main_window.SIPPCompare()
|
|
||||||
|
|
||||||
window.show()
|
window.show()
|
||||||
app.exec()
|
app.exec()
|
||||||
|
@ -9,7 +9,8 @@ import db_handler
|
|||||||
|
|
||||||
|
|
||||||
class SIPPCompare(QMainWindow):
|
class SIPPCompare(QMainWindow):
|
||||||
def __init__(self):
|
# Receive instance of PlatformEdit() as parameter
|
||||||
|
def __init__(self, plat_edit_win: QWidget):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
# Import Qt Designer UI XML file
|
# Import Qt Designer UI XML file
|
||||||
uic.loadUi(resource_finder.get_res_path("gui/main_gui.ui"), self)
|
uic.loadUi(resource_finder.get_res_path("gui/main_gui.ui"), self)
|
||||||
@ -35,12 +36,14 @@ class SIPPCompare(QMainWindow):
|
|||||||
|
|
||||||
# Create window objects
|
# Create window objects
|
||||||
self.db = db_handler.DBHandler()
|
self.db = db_handler.DBHandler()
|
||||||
|
self.platform_win = plat_edit_win
|
||||||
self.platform_list_win = platform_list.PlatformList(self.db)
|
self.platform_list_win = platform_list.PlatformList(self.db)
|
||||||
self.output_win = output_window.OutputWindow()
|
self.output_win = output_window.OutputWindow()
|
||||||
|
|
||||||
# Handle events
|
# Handle events
|
||||||
self.calc_but.clicked.connect(self.calculate_fees)
|
self.calc_but.clicked.connect(self.calculate_fees)
|
||||||
# Menu bar entry (File -> Edit Platforms)
|
# Menu bar entry (File -> Edit Platforms)
|
||||||
|
#self.actionEdit_Platforms.triggered.connect(self.show_platform_edit)
|
||||||
self.actionList_Platforms.triggered.connect(self.show_platform_list)
|
self.actionList_Platforms.triggered.connect(self.show_platform_list)
|
||||||
# Update percentage mix label when slider moved
|
# Update percentage mix label when slider moved
|
||||||
self.mix_slider.valueChanged.connect(self.update_slider_lab)
|
self.mix_slider.valueChanged.connect(self.update_slider_lab)
|
||||||
@ -61,8 +64,6 @@ class SIPPCompare(QMainWindow):
|
|||||||
self.fund_trades_combo.setCurrentText(str(prev_session_data["fund_trades"]))
|
self.fund_trades_combo.setCurrentText(str(prev_session_data["fund_trades"]))
|
||||||
self.calc_but.setFocus()
|
self.calc_but.setFocus()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Display slider position as mix between two nums (funds/shares)
|
# Display slider position as mix between two nums (funds/shares)
|
||||||
def update_slider_lab(self):
|
def update_slider_lab(self):
|
||||||
slider_val = self.mix_slider.value()
|
slider_val = self.mix_slider.value()
|
||||||
@ -166,5 +167,9 @@ class SIPPCompare(QMainWindow):
|
|||||||
)
|
)
|
||||||
self.output_win.show()
|
self.output_win.show()
|
||||||
|
|
||||||
|
# Show the platform editor window (currently run-time only)
|
||||||
|
def show_platform_edit(self):
|
||||||
|
self.platform_win.show()
|
||||||
|
|
||||||
def show_platform_list(self):
|
def show_platform_list(self):
|
||||||
self.platform_list_win.show()
|
self.platform_list_win.show()
|
||||||
|
@ -4,30 +4,36 @@ from PyQt6.QtWidgets import QWidget, QLabel
|
|||||||
from PyQt6 import uic
|
from PyQt6 import uic
|
||||||
|
|
||||||
from widgets.fastedit_spinbox import FastEditQDoubleSpinBox
|
from widgets.fastedit_spinbox import FastEditQDoubleSpinBox
|
||||||
from data_struct import Platform
|
|
||||||
import main_window
|
import main_window
|
||||||
import resource_finder
|
import resource_finder
|
||||||
|
|
||||||
|
|
||||||
class PlatformEdit(QWidget):
|
class PlatformEdit(QWidget):
|
||||||
def __init__(self, plat: Platform):
|
def __init__(self, autofill: bool):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
# Import Qt Designer UI XML file
|
# Import Qt Designer UI XML file
|
||||||
uic.loadUi(resource_finder.get_res_path("gui/platform_edit.ui"), self)
|
uic.loadUi(resource_finder.get_res_path("gui/platform_edit.ui"), self)
|
||||||
self.setWindowIcon(QIcon(resource_finder.get_res_path("icon2.ico")))
|
self.setWindowIcon(QIcon(resource_finder.get_res_path("icon2.ico")))
|
||||||
|
|
||||||
# Initialise class variables
|
# Initialise class variables
|
||||||
self.plat = plat
|
# Create main window object, passing this instance as param
|
||||||
self.fund_plat_fee = self.plat.fund_plat_fee
|
self.main_win = main_window.SIPPCompare(self)
|
||||||
|
|
||||||
|
self.fund_plat_fee = []
|
||||||
|
self.plat_name = ""
|
||||||
|
self.fund_deal_fee = 0.0
|
||||||
|
self.share_plat_fee = 0.0
|
||||||
|
self.share_plat_max_fee = 0.0
|
||||||
|
self.share_deal_fee = 0.0
|
||||||
|
self.share_deal_reduce_trades = 0.0
|
||||||
|
self.share_deal_reduce_amount = 0.0
|
||||||
self.widgets_list_list = []
|
self.widgets_list_list = []
|
||||||
|
|
||||||
self.fund_fee_rows = len(self.plat.fund_plat_fee[0])
|
self.fund_fee_rows = 1
|
||||||
"""
|
|
||||||
# Debugging feature: set with "--DEBUG_AUTOFILL" cmd argument
|
# Debugging feature: set with "--DEBUG_AUTOFILL" cmd argument
|
||||||
self.autofill = autofill
|
self.autofill = autofill
|
||||||
if autofill:
|
if autofill:
|
||||||
self.save_but.setEnabled(True)
|
self.save_but.setEnabled(True)
|
||||||
"""
|
|
||||||
|
|
||||||
self.required_fields = [
|
self.required_fields = [
|
||||||
self.share_plat_fee_box,
|
self.share_plat_fee_box,
|
||||||
@ -58,54 +64,6 @@ class PlatformEdit(QWidget):
|
|||||||
False
|
False
|
||||||
]
|
]
|
||||||
|
|
||||||
if self.plat.plat_name is None:
|
|
||||||
self.check_boxes_ticked[0] = False
|
|
||||||
self.plat_name_check.setChecked(False)
|
|
||||||
else:
|
|
||||||
self.check_boxes_ticked[0] = True
|
|
||||||
self.plat_name_check.setChecked(True)
|
|
||||||
self.plat_name_box.setText(self.plat.plat_name)
|
|
||||||
|
|
||||||
if self.plat.fund_deal_fee is None:
|
|
||||||
self.check_boxes_ticked[1] = False
|
|
||||||
self.plat_fund_deal_fee_check.setChecked(False)
|
|
||||||
else:
|
|
||||||
self.check_boxes_ticked[1] = True
|
|
||||||
self.fund_deal_fee_check.setChecked(True)
|
|
||||||
self.fund_deal_fee_box.setValue(self.plat.fund_deal_fee)
|
|
||||||
|
|
||||||
self.share_plat_fee_box.setValue(self.plat.share_plat_fee * 100)
|
|
||||||
|
|
||||||
if self.plat.share_plat_max_fee is None:
|
|
||||||
self.check_boxes_ticked[2] = False
|
|
||||||
self.share_plat_max_fee_check.setChecked(False)
|
|
||||||
else:
|
|
||||||
self.check_boxes_ticked[2] = True
|
|
||||||
self.share_plat_max_fee_check.setChecked(True)
|
|
||||||
self.share_plat_max_fee_box.setValue(self.plat.share_plat_max_fee)
|
|
||||||
|
|
||||||
self.share_deal_fee_box.setValue(self.plat.share_deal_fee)
|
|
||||||
|
|
||||||
if self.plat.share_deal_reduce_trades is None:
|
|
||||||
self.check_boxes_ticked[3] = False
|
|
||||||
self.share_deal_reduce_trades_check.setChecked(False)
|
|
||||||
else:
|
|
||||||
self.check_boxes_ticked[3] = True
|
|
||||||
self.share_deal_reduce_trades_check.setChecked(True)
|
|
||||||
self.share_deal_reduce_trades_box.setValue(int(self.plat.share_deal_reduce_trades))
|
|
||||||
|
|
||||||
if self.plat.share_deal_reduce_trades is None:
|
|
||||||
self.check_boxes_ticked[4] = False
|
|
||||||
self.share_deal_reduce_amount_check.setChecked(False)
|
|
||||||
else:
|
|
||||||
self.check_boxes_ticked[4] = True
|
|
||||||
self.share_deal_reduce_amount_check.setChecked(True)
|
|
||||||
self.share_deal_reduce_amount_box.setValue(self.plat.share_deal_reduce_amount)
|
|
||||||
|
|
||||||
self.first_tier_box.setValue(self.plat.fund_plat_fee[0][1])
|
|
||||||
self.first_tier_fee_box.setValue(self.plat.fund_plat_fee[1][1])
|
|
||||||
self.add_row(loading=True)
|
|
||||||
|
|
||||||
# Handle events
|
# Handle events
|
||||||
for field in self.required_fields:
|
for field in self.required_fields:
|
||||||
field.valueChanged.connect(self.check_valid)
|
field.valueChanged.connect(self.check_valid)
|
||||||
@ -150,7 +108,6 @@ class PlatformEdit(QWidget):
|
|||||||
|
|
||||||
# Get fee structure variables from user input when "Save" clicked
|
# Get fee structure variables from user input when "Save" clicked
|
||||||
def init_variables(self):
|
def init_variables(self):
|
||||||
"""
|
|
||||||
# If debugging, save time by hardcoding
|
# If debugging, save time by hardcoding
|
||||||
if self.autofill:
|
if self.autofill:
|
||||||
self.plat_name = "AJBell"
|
self.plat_name = "AJBell"
|
||||||
@ -166,15 +123,14 @@ class PlatformEdit(QWidget):
|
|||||||
self.share_deal_reduce_amount = 3.50
|
self.share_deal_reduce_amount = 3.50
|
||||||
self.check_boxes_ticked = [True, True, True, True, True]
|
self.check_boxes_ticked = [True, True, True, True, True]
|
||||||
else:
|
else:
|
||||||
"""
|
self.plat_name = self.plat_name_box.text()
|
||||||
self.plat_name = self.plat_name_box.text()
|
self.fund_plat_fee = self.create_plat_fee_struct()
|
||||||
self.fund_plat_fee = self.create_plat_fee_struct()
|
self.fund_deal_fee = float(self.fund_deal_fee_box.value())
|
||||||
self.fund_deal_fee = float(self.fund_deal_fee_box.value())
|
self.share_plat_fee = float(self.share_plat_fee_box.value()) / 100
|
||||||
self.share_plat_fee = float(self.share_plat_fee_box.value()) / 100
|
self.share_plat_max_fee = float(self.share_plat_max_fee_box.value())
|
||||||
self.share_plat_max_fee = float(self.share_plat_max_fee_box.value())
|
self.share_deal_fee = float(self.share_deal_fee_box.value())
|
||||||
self.share_deal_fee = float(self.share_deal_fee_box.value())
|
self.share_deal_reduce_trades = float(self.share_deal_reduce_trades_box.value())
|
||||||
self.share_deal_reduce_trades = float(self.share_deal_reduce_trades_box.value())
|
self.share_deal_reduce_amount = float(self.share_deal_reduce_amount_box.value())
|
||||||
self.share_deal_reduce_amount = float(self.share_deal_reduce_amount_box.value())
|
|
||||||
|
|
||||||
# Once user input is received show main window
|
# Once user input is received show main window
|
||||||
self.main_win.show()
|
self.main_win.show()
|
||||||
@ -259,63 +215,50 @@ class PlatformEdit(QWidget):
|
|||||||
max_band = self.first_tier_box.value()
|
max_band = self.first_tier_box.value()
|
||||||
self.val_above_lab.setText(f"on the value above £{int(max_band)} there is no charge")
|
self.val_above_lab.setText(f"on the value above £{int(max_band)} there is no charge")
|
||||||
|
|
||||||
def add_row(self, loading: bool = False):
|
def add_row(self):
|
||||||
if loading:
|
|
||||||
rows_needed = self.fund_fee_rows
|
|
||||||
else:
|
|
||||||
rows_needed = 1
|
|
||||||
|
|
||||||
widgets = []
|
widgets = []
|
||||||
for x in range(rows_needed):
|
font = QFont()
|
||||||
font = QFont()
|
font.setPointSize(11)
|
||||||
font.setPointSize(11)
|
|
||||||
|
|
||||||
widgets.append(QLabel(self.gridLayoutWidget_2))
|
widgets.append(QLabel(self.gridLayoutWidget_2))
|
||||||
widgets[0].setFont(font)
|
widgets[0].setFont(font)
|
||||||
|
|
||||||
widgets.append(FastEditQDoubleSpinBox(self.gridLayoutWidget_2))
|
widgets.append(FastEditQDoubleSpinBox(self.gridLayoutWidget_2))
|
||||||
widgets[1].setPrefix("£")
|
widgets[1].setPrefix("£")
|
||||||
widgets[1].setMaximum(9999999)
|
widgets[1].setMaximum(9999999)
|
||||||
widgets[1].setButtonSymbols(FastEditQDoubleSpinBox.ButtonSymbols.NoButtons)
|
widgets[1].setButtonSymbols(FastEditQDoubleSpinBox.ButtonSymbols.NoButtons)
|
||||||
widgets[1].setFont(font)
|
widgets[1].setFont(font)
|
||||||
if loading:
|
widgets[1].valueChanged.connect(self.check_valid)
|
||||||
widgets[1].setValue(self.plat.fund_plat_fee[0][x+1])
|
widgets[1].valueChanged.connect(self.update_tier_labels)
|
||||||
widgets[1].valueChanged.connect(self.check_valid)
|
|
||||||
widgets[1].valueChanged.connect(self.update_tier_labels)
|
|
||||||
|
|
||||||
widgets.append(QLabel(self.gridLayoutWidget_2))
|
widgets.append(QLabel(self.gridLayoutWidget_2))
|
||||||
widgets[2].setText(f"the fee is")
|
widgets[2].setText(f"the fee is")
|
||||||
widgets[2].setFont(font)
|
widgets[2].setFont(font)
|
||||||
|
|
||||||
widgets.append(FastEditQDoubleSpinBox(self.gridLayoutWidget_2))
|
widgets.append(FastEditQDoubleSpinBox(self.gridLayoutWidget_2))
|
||||||
widgets[3].setSuffix("%")
|
widgets[3].setSuffix("%")
|
||||||
widgets[3].setMaximum(100)
|
widgets[3].setMaximum(100)
|
||||||
widgets[3].setButtonSymbols(FastEditQDoubleSpinBox.ButtonSymbols.NoButtons)
|
widgets[3].setButtonSymbols(FastEditQDoubleSpinBox.ButtonSymbols.NoButtons)
|
||||||
widgets[3].setFont(font)
|
widgets[3].setFont(font)
|
||||||
if loading:
|
widgets[3].valueChanged.connect(self.check_valid)
|
||||||
widgets[3].setValue(self.plat.fund_plat_fee[1][x+1])
|
|
||||||
widgets[3].valueChanged.connect(self.check_valid)
|
|
||||||
|
|
||||||
# TODO: why 28.5?
|
# TODO: why 28.5?
|
||||||
self.gridLayoutWidget_2.setGeometry(11, 309, 611, int(round(28.5 * (self.fund_fee_rows + 1), 0)))
|
self.gridLayoutWidget_2.setGeometry(11, 309, 611, int(round(28.5 * (self.fund_fee_rows + 1), 0)))
|
||||||
for i in range(len(widgets)):
|
for i in range(len(widgets)):
|
||||||
self.gridLayout_2.addWidget(widgets[i], self.fund_fee_rows, i, 1, 1)
|
self.gridLayout_2.addWidget(widgets[i], self.fund_fee_rows, i, 1, 1)
|
||||||
|
|
||||||
if not loading:
|
self.fund_fee_rows += 1
|
||||||
self.fund_fee_rows += 1
|
|
||||||
|
|
||||||
self.widgets_list_list.append(widgets)
|
self.widgets_list_list.append(widgets)
|
||||||
cur_label_idx = self.gridLayout_2.indexOf(widgets[0])
|
cur_label_idx = self.gridLayout_2.indexOf(widgets[0])
|
||||||
cur_box_idx = self.gridLayout_2.indexOf(widgets[1])
|
cur_box_idx = self.gridLayout_2.indexOf(widgets[1])
|
||||||
cur_label_pos = list(self.gridLayout_2.getItemPosition(cur_label_idx))[:2]
|
cur_label_pos = list(self.gridLayout_2.getItemPosition(cur_label_idx))[:2]
|
||||||
cur_box_pos = list(self.gridLayout_2.getItemPosition(cur_box_idx))[:2]
|
cur_box_pos = list(self.gridLayout_2.getItemPosition(cur_box_idx))[:2]
|
||||||
|
|
||||||
prev_box_row = cur_box_pos[0] - 1
|
prev_box_row = cur_box_pos[0] - 1
|
||||||
prev_box_item = self.gridLayout_2.itemAtPosition(prev_box_row, cur_box_pos[1]).widget()
|
prev_box_item = self.gridLayout_2.itemAtPosition(prev_box_row, cur_box_pos[1]).widget()
|
||||||
#if loading:
|
cur_label_item = self.gridLayout_2.itemAtPosition(cur_label_pos[0], cur_label_pos[1]).widget()
|
||||||
# prev_box_item.setValue(self.plat.fund_plat_fee[0][x+1])
|
cur_label_item.setText(f"between £{int(prev_box_item.value())} and")
|
||||||
cur_label_item = self.gridLayout_2.itemAtPosition(cur_label_pos[0], cur_label_pos[1]).widget()
|
|
||||||
cur_label_item.setText(f"between £{int(prev_box_item.value())} and")
|
|
||||||
|
|
||||||
if self.fund_fee_rows > 1:
|
if self.fund_fee_rows > 1:
|
||||||
self.del_row_but.setEnabled(True)
|
self.del_row_but.setEnabled(True)
|
||||||
|
@ -4,8 +4,6 @@ from PyQt6.QtCore import QRegularExpression
|
|||||||
from PyQt6 import uic
|
from PyQt6 import uic
|
||||||
|
|
||||||
import resource_finder
|
import resource_finder
|
||||||
import data_struct
|
|
||||||
import platform_edit
|
|
||||||
|
|
||||||
|
|
||||||
class PlatformRename(QWidget):
|
class PlatformRename(QWidget):
|
||||||
@ -30,11 +28,8 @@ class PlatformList(QWidget):
|
|||||||
self.setWindowIcon(QIcon(resource_finder.get_res_path("icon2.ico")))
|
self.setWindowIcon(QIcon(resource_finder.get_res_path("icon2.ico")))
|
||||||
|
|
||||||
self.plat_list_dialog = PlatformRename()
|
self.plat_list_dialog = PlatformRename()
|
||||||
self.p_edit = None
|
|
||||||
self.db = db
|
self.db = db
|
||||||
self.plat_name_list = self.db.retrieve_plat_list()
|
self.plat_name_list = self.db.retrieve_plat_list()
|
||||||
self.plat_list = self.db.retrieve_platforms()
|
|
||||||
print(self.plat_list[1].fund_plat_fee)
|
|
||||||
print(self.plat_name_list)
|
print(self.plat_name_list)
|
||||||
|
|
||||||
for platform in self.plat_name_list:
|
for platform in self.plat_name_list:
|
||||||
@ -44,29 +39,6 @@ class PlatformList(QWidget):
|
|||||||
|
|
||||||
# Handle events
|
# Handle events
|
||||||
self.add_plat_but.clicked.connect(self.add_platform)
|
self.add_plat_but.clicked.connect(self.add_platform)
|
||||||
self.del_plat_but.clicked.connect(self.remove_platform)
|
|
||||||
self.edit_plat_but.clicked.connect(self.edit_platform)
|
|
||||||
self.plat_enabled_check.checkStateChanged.connect(self.toggle_platform_state)
|
|
||||||
self.platListWidget.currentRowChanged.connect(self.get_enabled_state)
|
|
||||||
|
|
||||||
def add_platform(self):
|
def add_platform(self):
|
||||||
self.plat_list_dialog.show()
|
self.plat_list_dialog.show()
|
||||||
|
|
||||||
def get_enabled_state(self):
|
|
||||||
index = self.platListWidget.currentRow()
|
|
||||||
is_enabled = self.plat_list[index].enabled
|
|
||||||
if is_enabled:
|
|
||||||
self.plat_enabled_check.setChecked(True)
|
|
||||||
else:
|
|
||||||
self.plat_enabled_check.setChecked(False)
|
|
||||||
|
|
||||||
def edit_platform(self):
|
|
||||||
index = self.platListWidget.currentRow()
|
|
||||||
self.p_edit = platform_edit.PlatformEdit(self.plat_list[index])
|
|
||||||
self.p_edit.show()
|
|
||||||
|
|
||||||
def toggle_platform_state(self):
|
|
||||||
return None
|
|
||||||
|
|
||||||
def remove_platform(self):
|
|
||||||
return None
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user