So I am trying to make it so that the combo boxes in my GUI refresh when the user puts in an input. That part is easy an not a problem. The problem is that when a user inputs a choice in a different box, it ignores the restrictions set by the previous box. Let me show you.
In this image, it shows that there is only one option when the Type input is NA which is Non-Reversible which is correct and what it should be. However, if I change one of the other boxes, I get this image:
As you can see in this second image, it set the Rotation Combo Box to have Non-Reversible AND Reversible, which is not correct. It should remain just Non-Reversible.
Here is a snippet of my code.
if event == 'type':
if v['board'] == 'Select Option':
board_op.clear()
if v['volt'] == 'Select Option':
volt_op.clear()
if v['rot'] == 'Select Option':
rot_op.clear()
if v['start'] == 'Select Option':
start_op.clear()
if v['overl'] == 'Select Option':
overl_op.clear()
if v['lead'] == 'Select Option':
lead_op.clear()
if v['switch'] == 'Select Option':
switch_op.clear()
i = 0
while i < len(workbook):
if workbook['Type:'][i] == v['type']:
if v['board'] == 'Select Option':
board_op.append(workbook['Board:'][i])
if v['volt'] == 'Select Option':
volt_op.append(workbook['Voltage:'][i])
if v['rot'] == 'Select Option':
rot_op.append(workbook['Rotation:'][i])
if v['start'] == 'Select Option':
start_op.append(workbook['Start:'][i])
if v['overl'] == 'Select Option':
overl_op.append(workbook['Overload:'][i])
if v['lead'] == 'Select Option':
lead_op.append(workbook['Lead:'][i])
if v['switch'] == 'Select Option':
switch_op.append(workbook['Switch:'][i])
i += 1
if v['board'] == 'Select Option':
board_op = list(dict.fromkeys(board_op))
if v['volt'] == 'Select Option':
volt_op = list(dict.fromkeys(volt_op))
if v['rot'] == 'Select Option':
rot_op = list(dict.fromkeys(rot_op))
if v['start'] == 'Select Option':
start_op = list(dict.fromkeys(start_op))
if v['overl'] == 'Select Option':
overl_op = list(dict.fromkeys(overl_op))
if v['lead'] == 'Select Option':
lead_op = list(dict.fromkeys(lead_op))
if v['switch'] == 'Select Option':
switch_op = list(dict.fromkeys(switch_op))
if v['board'] == 'Select Option':
win['board'].update(value='Select Option', values=board_op)
if v['volt'] == 'Select Option':
win['volt'].update(value='Select Option', values=volt_op)
if v['rot'] == 'Select Option':
win['rot'].update(value='Select Option', values=rot_op)
if v['start'] == 'Select Option':
win['start'].update(value='Select Option', values=start_op)
if v['overl'] == 'Select Option':
win['overl'].update(value='Select Option', values=overl_op)
if v['lead'] == 'Select Option':
win['lead'].update(value='Select Option', values=lead_op)
if v['switch'] == 'Select Option':
win['switch'].update(value='Select Option', values=switch_op)
if event == 'board':
if v['type'] == 'Select Option':
type_op.clear()
if v['volt'] == 'Select Option':
volt_op.clear()
if v['rot'] == 'Select Option':
rot_op.clear()
if v['start'] == 'Select Option':
start_op.clear()
if v['overl'] == 'Select Option':
overl_op.clear()
if v['lead'] == 'Select Option':
lead_op.clear()
if v['switch'] == 'Select Option':
switch_op.clear()
i = 0
while i < len(workbook):
if workbook['Board:'][i] == v['board']:
if v['type'] == 'Select Option':
type_op.append(workbook['Type:'][i])
if v['volt'] == 'Select Option':
volt_op.append(workbook['Voltage:'][i])
if v['rot'] == 'Select Option':
rot_op.append(workbook['Rotation:'][i])
if v['start'] == 'Select Option':
start_op.append(workbook['Start:'][i])
if v['overl'] == 'Select Option':
overl_op.append(workbook['Overload:'][i])
if v['lead'] == 'Select Option':
lead_op.append(workbook['Lead:'][i])
if v['switch'] == 'Select Option':
switch_op.append(workbook['Switch:'][i])
i += 1
if v['type'] == 'Select Option':
type_op = list(dict.fromkeys(type_op))
if v['volt'] == 'Select Option':
volt_op = list(dict.fromkeys(volt_op))
if v['rot'] == 'Select Option':
rot_op = list(dict.fromkeys(rot_op))
if v['start'] == 'Select Option':
start_op = list(dict.fromkeys(start_op))
if v['overl'] == 'Select Option':
overl_op = list(dict.fromkeys(overl_op))
if v['lead'] == 'Select Option':
lead_op = list(dict.fromkeys(lead_op))
if v['switch'] == 'Select Option':
switch_op = list(dict.fromkeys(switch_op))
if v['type'] == 'Select Option':
win['type'].update(value='Select Option', values=type_op)
if v['volt'] == 'Select Option':
win['volt'].update(value='Select Option', values=volt_op)
if v['rot'] == 'Select Option':
win['rot'].update(value='Select Option', values=rot_op)
if v['start'] == 'Select Option':
win['start'].update(value='Select Option', values=start_op)
if v['overl'] == 'Select Option':
win['overl'].update(value='Select Option', values=overl_op)
if v['lead'] == 'Select Option':
win['lead'].update(value='Select Option', values=lead_op)
if v['switch'] == 'Select Option':
win['switch'].update(value='Select Option', values=switch_op)
This is just a snippet, it continues on for each of my inputs.
So, here is the thing, I know what is causing the problem. The problem is being caused by the line of code that says
if v['rot'] == 'Select Option':
The original purpose of the line was to make sure that if the user input a choice into the combo box then it would not change the input. Which it does that job fine, but in the case like I showed above, since the input remained "Select Option" it saw fit to go ahead and change the combo options despite the fact they were defined by my previous input. It just ignores the previous inputs. So I know what my issue is, but not how to fix it.


Aucun commentaire:
Enregistrer un commentaire