mirror of
https://github.com/RolandWH/SIPPCompare.git
synced 2025-03-14 13:51:36 +00:00
add input validation on combo boxes
This commit is contained in:
parent
59f05a3f38
commit
1f132da9b6
@ -7,19 +7,19 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>420</width>
|
<width>420</width>
|
||||||
<height>250</height>
|
<height>228</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>420</width>
|
<width>420</width>
|
||||||
<height>250</height>
|
<height>228</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>420</width>
|
<width>420</width>
|
||||||
<height>250</height>
|
<height>228</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -35,7 +35,7 @@
|
|||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>401</width>
|
<width>401</width>
|
||||||
<height>191</height>
|
<height>171</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<layout class="QFormLayout" name="formLayout">
|
||||||
@ -58,6 +58,28 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QDoubleSpinBox" name="value_input">
|
||||||
|
<property name="frame">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="buttonSymbols">
|
||||||
|
<enum>QAbstractSpinBox::ButtonSymbols::NoButtons</enum>
|
||||||
|
</property>
|
||||||
|
<property name="specialValueText">
|
||||||
|
<string>£</string>
|
||||||
|
</property>
|
||||||
|
<property name="correctionMode">
|
||||||
|
<enum>QAbstractSpinBox::CorrectionMode::CorrectToNearestValue</enum>
|
||||||
|
</property>
|
||||||
|
<property name="prefix">
|
||||||
|
<string>£</string>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>999999999.990000009536743</double>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="1" column="0" colspan="2">
|
<item row="1" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="mix_lab">
|
<widget class="QLabel" name="mix_lab">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -91,13 +113,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
|
||||||
<widget class="QComboBox" name="share_trades_combo">
|
|
||||||
<property name="editable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QLabel" name="fund_trades_lab">
|
<widget class="QLabel" name="fund_trades_lab">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -114,31 +129,19 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="5" column="0" colspan="2">
|
<item row="5" column="0" colspan="2">
|
||||||
<widget class="QPushButton" name="calc_but">
|
<widget class="QPushButton" name="calc_but">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Calculate</string>
|
<string>Calculate</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QDoubleSpinBox" name="value_input">
|
<widget class="QComboBox" name="share_trades_combo">
|
||||||
<property name="frame">
|
<property name="editable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="buttonSymbols">
|
|
||||||
<enum>QAbstractSpinBox::ButtonSymbols::NoButtons</enum>
|
|
||||||
</property>
|
|
||||||
<property name="specialValueText">
|
|
||||||
<string>£</string>
|
|
||||||
</property>
|
|
||||||
<property name="correctionMode">
|
|
||||||
<enum>QAbstractSpinBox::CorrectionMode::CorrectToNearestValue</enum>
|
|
||||||
</property>
|
|
||||||
<property name="prefix">
|
|
||||||
<string>£</string>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<double>999999999.990000009536743</double>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@ -172,6 +175,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>value_input</tabstop>
|
||||||
|
<tabstop>mix_slider</tabstop>
|
||||||
|
<tabstop>share_trades_combo</tabstop>
|
||||||
|
<tabstop>fund_trades_combo</tabstop>
|
||||||
|
<tabstop>calc_but</tabstop>
|
||||||
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from PyQt6.QtGui import QIntValidator
|
from PyQt6.QtGui import QIntValidator
|
||||||
from PyQt6.QtWidgets import QMainWindow
|
from PyQt6.QtWidgets import QMainWindow, QWidget
|
||||||
from PyQt6 import uic
|
from PyQt6 import uic
|
||||||
|
|
||||||
import output_window
|
import output_window
|
||||||
@ -7,7 +7,7 @@ import output_window
|
|||||||
|
|
||||||
class SIPPCompare(QMainWindow):
|
class SIPPCompare(QMainWindow):
|
||||||
# Receive instance of PlatformEdit() as parameter
|
# Receive instance of PlatformEdit() as parameter
|
||||||
def __init__(self, plat_edit_win):
|
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("gui/main_gui.ui", self)
|
uic.loadUi("gui/main_gui.ui", self)
|
||||||
@ -39,6 +39,9 @@ class SIPPCompare(QMainWindow):
|
|||||||
self.actionEdit_Platforms.triggered.connect(self.show_platform_edit)
|
self.actionEdit_Platforms.triggered.connect(self.show_platform_edit)
|
||||||
# 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)
|
||||||
|
#self.value_input.valueChanged.connect(self.check_valid)
|
||||||
|
self.share_trades_combo.currentTextChanged.connect(self.check_valid)
|
||||||
|
self.fund_trades_combo.currentTextChanged.connect(self.check_valid)
|
||||||
|
|
||||||
# Set validators
|
# Set validators
|
||||||
self.share_trades_combo.setValidator(QIntValidator(0, 999))
|
self.share_trades_combo.setValidator(QIntValidator(0, 999))
|
||||||
@ -50,6 +53,13 @@ class SIPPCompare(QMainWindow):
|
|||||||
mix_lab_str = f"Investment mix (funds {slider_val}% / shares {100 - slider_val}%)"
|
mix_lab_str = f"Investment mix (funds {slider_val}% / shares {100 - slider_val}%)"
|
||||||
self.mix_lab.setText(mix_lab_str)
|
self.mix_lab.setText(mix_lab_str)
|
||||||
|
|
||||||
|
def check_valid(self):
|
||||||
|
if self.share_trades_combo.currentText() != "" \
|
||||||
|
and self.fund_trades_combo.currentText() != "":
|
||||||
|
self.calc_but.setEnabled(True)
|
||||||
|
else:
|
||||||
|
self.calc_but.setEnabled(False)
|
||||||
|
|
||||||
# Get variables from platform editor input fields
|
# Get variables from platform editor input fields
|
||||||
def init_variables(self):
|
def init_variables(self):
|
||||||
self.plat_name = self.platform_win.get_plat_name()
|
self.plat_name = self.platform_win.get_plat_name()
|
||||||
@ -69,7 +79,7 @@ class SIPPCompare(QMainWindow):
|
|||||||
self.fund_plat_fees = 0
|
self.fund_plat_fees = 0
|
||||||
value_num = float(self.value_input.value())
|
value_num = float(self.value_input.value())
|
||||||
# Funds/shares mix
|
# Funds/shares mix
|
||||||
slider_val = self.mix_slider.value()
|
slider_val: int = self.mix_slider.value()
|
||||||
funds_value = (slider_val / 100) * value_num
|
funds_value = (slider_val / 100) * value_num
|
||||||
fund_trades_num = int(self.fund_trades_combo.currentText())
|
fund_trades_num = int(self.fund_trades_combo.currentText())
|
||||||
self.fund_deal_fees = fund_trades_num * self.fund_deal_fee
|
self.fund_deal_fees = fund_trades_num * self.fund_deal_fee
|
||||||
|
Loading…
x
Reference in New Issue
Block a user