Python question - how do I get an OK button on my popups

ww2commander

Emperor
Joined
Aug 23, 2003
Messages
1,243
Location
Australia
Ok, I just started taking my first baby steps into the world of python and have already come to an embarressing dead-end :blush:

I am trying to work out how to get popup boxes and have followed the tutorial from this forum. The only problem is that the modified snippet of code I tested works except I dont get an 'OK/close' button to click on....it just shows the popup and no way to get rid of it.

Please point out what I need to add to get a simple 'Hello world' popup that I can click ok to.

Spoiler :
PHP:
        def onGameStart(self, argsList):
                for iPlayer in range(gc.getMAX_PLAYERS()):
                        player = gc.getPlayer(iPlayer)
                        if (player.isAlive() and player.isHuman()):
                                    popupInfo = CyPopupInfo()
                                    popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON)
                                    popupInfo.setText('Hello world')
                                    popupInfo.addPopup(iPlayer)

Please be mindful that I am just learning :sad:
 
This is what I use:
Code:
	def popupsingle(self, player, title, text):
		if player.isHuman():
			popup = PyPopup.PyPopup(-1)
			popup.addSeparator()
			popup.setHeaderString(title)
			popup.setBodyString(text)
			popup.launch(true, PopupStates.POPUPSTATE_QUEUED)

Whenever I need a popup, I simply add this text into my code:
Code:
player = gc.getPlayer(*number*)
title = 'This is the Title!"
text = 'And this is the text.'
self.popupsingle(player, title, text)

Basically, I think you're using the many option popup, when you want this simpler one option popup.
 
Worked perfectly....and it actually suits what I need to do better.:worship:

I plan to use popup boxes everywhere for my scenario based on date triggers.

Is it be possible to insert an image along with text?....lets say an event pops up that says 'The Battle of Kursk has begun' and a picture of a tank appears with it.
 
Sorry for my stupidity....which thread are you referring to?
 
Ok found it. Thanks Paasky/Kael.

Yes thats the same tut I was using :)
 
Back
Top Bottom