phungus420
Deity
- Joined
- Mar 1, 2003
- Messages
- 6,296
I tried googling this, and now have a basic understanding of the for loop, something which confused me before. So that's all good, but I couldn't find the answer to my question.
Say I have an unknown word stored in a variable called szWORD. So I set up a loop like:
How do I determine how many letters are in the variable?
How this relates to civ, is I'm trying to get this code to work:
But I can't find anything with google telling me how to get a count of how many values were returned in the loop. In this case I just want an if > 1 returned values, but I'm also just interested in general how to do this with a for loop.
Say I have an unknown word stored in a variable called szWORD. So I set up a loop like:
Code:
for letter in szWORD
#number of letters in szWORD
How this relates to civ, is I'm trying to get this code to work:
Code:
def placeCiv(self):
screen = self.top.getScreen()
for iCiv in range(gc.getNumCivilizationInfos()):
civ = gc.getCivilizationInfo(iCiv)
if civ.isLeaders(self.iLeader):
#if multiple civs
panelName = self.top.getNextWidgetName()
screen.addPanel( panelName, localText.getText("TXT_KEY_PEDIA_CATEGORY_CIV", ()), "", False, True, self.X_CIVS, self.Y_CIVS, self.W_CIVS, self.H_CIVS, PanelStyles.PANEL_STYLE_BLUE50 )
screen.attachLabel(panelName, "", " ")
screen.attachImageButton(panelName, "", civ.getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_CIV, iCiv, 1, False)
#else
screen.setImageButton(self.top.getNextWidgetName(), civ.getButton(), self.X_CIV, self.Y_CIV, self.W_CIV, self.H_CIV, WidgetTypes.WIDGET_PEDIA_JUMP_TO_CIV, iCiv, 1)