DomC Posted February 27, 2022 Share Posted February 27, 2022 Hello Would be great if anybody could help me. At the end result I want to be able to exchange a popup's choices. What I am trying to do is, that I delete the items with vs.RemoveChoice() and build it new with a loop through my choices. I think I make something wrong by indexing with "AddChoice" or "RemoveChoice" just remove the string not shorten the Choice Numbers. My script: choices1 = ['choice1', 'choice2', 'choice3', 'choice4'] choices2 = ['choiceA', 'choiceB'] def CreateMyDialog(): vs.dialogid = vs.CreateLayout('Dialog Name', 0, 'OK', 'Cancel') dialogID = vs.dialogid vs.CreateStaticText(dialogID, 10, 'Popup', 60 ) vs.CreatePullDownMenu(dialogID, 11, 40) vs.CreateCheckBox(dialogID, 12, 'Change Popup') vs.SetFirstLayoutItem(dialogID, 10) vs.SetBelowItem(dialogID, 10, 11, 0, 1) vs.SetBelowItem(dialogID, 11, 12, 0, 1) return vs.RunLayoutDialogN(dialogID, Dialog_Handler, 0) def Dialog_Handler(item, data): dialogID = vs.dialogid if item == 12255: # enter Dialog 12255 -> 12256 exit dialog for i in range(len(choices1)): vs.AddChoice(dialogID, 11, choices1[i], i) if item == 12: #checkbox if data: #checkbox True num_choices = vs.GetChoiceCount(dialogID, 11) for i in range(num_choices): vs.RemoveChoice(dialogID, 11, i) for i in range(len(choices2)): vs.AddChoice(dialogID, 11, choices2[i], i) if not data: #checkbox False num_choices = vs.GetChoiceCount(dialogID, 11) for i in range(num_choices): vs.RemoveChoice(dialogID, 11, i) for i in range(len(choices1)): vs.AddChoice(dialogID, 11, choices1[i], i) result = CreateMyDialog() Quote Link to comment
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.