[PYTHON] List boxes! Please Help!

Zebra 9

Emperor
Joined
May 17, 2006
Messages
1,554
Location
Middle of Cyberspace
Ok, I'm working on changing a screen and I need a List Box. I got it on the screen and put all the selections I wanted. Now the problem is that I have no idea of what to do to access which selection was selected!!!:confused::cry:

I tryed all sorts of stuff and got no where. Please Help!
 
I tried that code and it doesn't seem to work. I think I did it right. well I have a zip with a log and some of the functions I'm using.
 

Attachments

I put your code into the Sevopedia and got the same results. Confirmed - getSelectedListBoxID and getSelectedListBoxString do not work as we think they should.

I did a search and these methods are not called from anywhere in the vanilla python or SDK code. Since CyGInterfaceScreen is not in the SDK and (mostly) undocumented, I cannot say if they are implemented at all.
 
Try a drop-down combo box. This is how I implement them:

CvEventManager.py:
Code:
def __init__(self):
..
..
..
          CvUtil.EventYourPopup : ('YourPopup', self.YourApply, self.YourBegin),
     }
..
..
..
        def YourBegin(self, argsList):
                CvYourEventManager.YourBox()
                return

        def YourApply(self, playerID, userData, popupReturn):
                CvYourEventManager.YourBoxHandler(playerID, userData, popupReturn)
                return

CvUtil.py:
Code:
Somewhere near the top:
..
EventYourPopup = 5100      # some unique number
..

CvYourEventManager.py:
Code:
        def YourBox(self):
                popup = PyPopup.PyPopup(CvUtil.EventYourPopup, contextType = EventContextTypes.EVENTCONTEXT_ALL)
                szTitle = localText.getText("TXT_KEY_YOUR_TITLE", ())
                szText = localText.getText("TXT_KEY_YOUR_TEXT", ())
                ListTypes = {
                    0 : 'Option1',
                    1 : 'Option2',
                    2 : 'Option3',
                    }
                popup.setHeaderString(szTitle)
                popup.addSeparator()
                popup.setBodyString(szText)
                popup.addSeparator()
                popup.createPythonPullDown('Select an option', 3)
                for i in range(0, len(ListTypes)):
                        popup.addPullDownString(ListTypes[i], i, 3)
                popup.popup.setSelectedPulldownID(1, 3)
                popup.addSeparator()
                popup.launch()

        def YourBoxHandler(self, playerID, netUserData, popupReturn):
                autoIdx = popupReturn.getSelectedPullDownValue(3)
                if(autoIdx == 0):
                        # do **** here
                elif(autoIdx == 1):
                        # do **** here
                elif(autoIdx == 2):
                        # do **** here
 
Sorry didn't realise it was for civic screen. Not mentioned anywhere.

I think you're stuck mate.
 
Back
Top Bottom