Here is what I am trying to do
Pseudocode:
if QCombobox[currentOption] == "option so and so":
do something
Here is what I have so far:
def modeChange(self):
content = self.combo_box.currentText()
if self.Change.isChecked():
if content == "Rule of 72":
self.head.show()
From this code, I want my application to check if the currentbox is at that specific option, if it is, show the head label, otherwise, show nothing when other options are selected
for context, this is what head refers to(as well as info on combobox variable):
self.combo_box = QComboBox(self)
self.combo_box.setGeometry(0, 0, 241, 61)
choices = ["Interest Rate","Net Profit Margin", "Rule of 72","Cash Flow", "Gains/Losses","Break-Even Equation"]
self.combo_box.addItems(choices)
self.combo_box.hide()
self.head = QLabel("Rule of 72", self)
self.head.setGeometry(0, 10, 400, 60)
self.head.hide()
My full code:
class CalculatorWindow(QtWidgets.QMainWindow, Ui_Calculator):
firstNum = None
userIsTypingSecondNumber = False
def __init__(self):
super().__init__()
self.setupUi(self)
self.show()
#Connect buttons
self.Zero.clicked.connect(self.digit_pressed)
self.One.clicked.connect(self.digit_pressed)
self.Two.clicked.connect(self.digit_pressed)
self.Three.clicked.connect(self.digit_pressed)
self.Four.clicked.connect(self.digit_pressed)
self.Five.clicked.connect(self.digit_pressed)
self.Six.clicked.connect(self.digit_pressed)
self.Seven.clicked.connect(self.digit_pressed)
self.Eight.clicked.connect(self.digit_pressed)
self.Nine.clicked.connect(self.digit_pressed)
self.period.clicked.connect(self.period_pressed)
self.Sign.clicked.connect(self.unary_pressed)
self.Percent.clicked.connect(self.unary_pressed)
self.Plus.clicked.connect(self.op_pressed)
self.Minus.clicked.connect(self.op_pressed)
self.Multiply.clicked.connect(self.op_pressed)
self.Divide.clicked.connect(self.op_pressed)
self.Equal.clicked.connect(self.Equal_pressed)
self.Clear.clicked.connect(self.clear_pressed)
self.Plus.setCheckable(True)
self.Minus.setCheckable(True)
self.Multiply.setCheckable(True)
self.Divide.setCheckable(True)
self.Percent.setChecked(True)
self.Sign.setChecked(True)
self.Change.clicked.connect(self.change_pressed)
self.Change.setCheckable(True)
self.modeChange()
def period_pressed(self):
self.label.setText(self.label.text() '.')
def op_pressed(self):
button = self.sender()
self.firstNum = float(self.label.text())
button.setChecked(True)
def change_pressed(self):
if self.Change.isChecked():
self.label.hide()
self.Change.setText("