Skip to content

Commit

Permalink
Working looped multiple QComboBox logic
Browse files Browse the repository at this point in the history
  • Loading branch information
shamith authored and shamith committed Jul 20, 2023
1 parent 698771e commit a3ac7e8
Showing 1 changed file with 35 additions and 17 deletions.
52 changes: 35 additions & 17 deletions gui/ui_template.py
Expand Up @@ -170,7 +170,6 @@ def closeEvent(self, event):
else:
event.ignore()


class Window(QMainWindow):
closed = QtCore.pyqtSignal()

Expand Down Expand Up @@ -677,22 +676,8 @@ def setupUi(self, MainWindow, main, folder):
combo_box_section_profile_list = []
combo_box_connection_location_list = []
for row in range(8):
combo_box_section_profile = QtWidgets.QComboBox()
combo_box_connection_location = QtWidgets.QComboBox()

for item in selectable_options['Section profile']:
value = None
if item in ['Angle', 'Star Angles', 'Back to Back Angles']:
value = selectable_options['Connection Location']['Angle']
elif item in ['Channel', 'Back to Back Channels']:
value = selectable_options['Connection Location']['Channel']
combo_box_section_profile.addItem(item, value)

combo_box_section_profile.activated.connect(
lambda: combo_box_connection_location.clear() or combo_box_connection_location.addItems(
selectable_options['Connection Location']['Angle' if combo_box_section_profile.currentText() in ['Angle', 'Star Angles', 'Back to Back Angles'] else 'Channel']
)
)

combo_box_section_profile, combo_box_connection_location = self.create_dependent_QComboBox(selectable_options)

combo_box_connection_location.addItems(selectable_options['Connection Location']['Angle'])

Expand Down Expand Up @@ -1420,6 +1405,39 @@ def setupUi(self, MainWindow, main, folder):
self.connectivity = None
self.fuse_model = None

def create_dependent_QComboBox(self, selectable_options):
'''
Created for creating Dependent QComboBox
Especially for `type == TYPE_TABLE_IN` in the Input Dock
Can be modified by passing more argument to keep the current functionality
required for `type == TYPE_TABLE_IN` by adding & changing the current args
of this method for future use.
If you don't know how to do it please don't modify this method as it may affect
the truss-connection-bolted module's connecting memeber attribute.
'''
combo_box_section_profile = QtWidgets.QComboBox()
combo_box_connection_location = QtWidgets.QComboBox()

for item in selectable_options['Section profile']:
value = None
if item in ['Angle', 'Star Angles', 'Back to Back Angles']:
value = selectable_options['Connection Location']['Angle']
elif item in ['Channel', 'Back to Back Channels']:
value = selectable_options['Connection Location']['Channel']
combo_box_section_profile.addItem(item, value)

combo_box_section_profile.activated.connect(
lambda: combo_box_connection_location.clear() or combo_box_connection_location.addItems(
selectable_options['Connection Location'][
'Angle' if combo_box_section_profile.currentText() in ['Angle', 'Star Angles',
'Back to Back Angles'] else 'Channel']
)
)

return combo_box_section_profile, combo_box_connection_location

def notification(self):
update_class = Update()
msg = update_class.notifi()
Expand Down

0 comments on commit a3ac7e8

Please sign in to comment.