I'm drawing a blank on what should be a simple question so any help is appreciated.
Is there a better way to handle all these 'if' statements rather than having them copied into each function?
This isn't the whole code but it should show my issue. Since they are all the same 'if' statements, can I just create a dedicated function for them then call them into each function or?
def btn_add_printer(self):
printer = str(self.ui.comboBox.currentText())
if printer == printer1_name_short:
network_printer = printer1_name_long
if printer == printer2_name_short:
network_printer = printer2_name_long
if printer == printer3_name_short:
network_printer = printer3_name_long
def btn_remove_printer(self):
printer = str(self.ui.comboBox.currentText())
if printer == printer1_name_short:
network_printer = printer1_name_long
if printer == printer2_name_short:
network_printer = printer2_name_long
if printer == printer3_name_short:
network_printer = printer3_name_long